A comprehensive guideline on developing iPhone/iPad app using SQLite Data and UITableView

Posted by Victoria Brinsley
4
Nov 20, 2014
726 Views
Image

iOS has received an incredible amount of appreciation from mobile app developers across the globe. This operating system has made data display in the UITableVIew a lot more quicker and simpler. In addition to this, SQLIte serves as a great data persistence facility that can be collaborated with SQLite to create perfect iOS applications. Through this blog, I'll be demonstrating the process of developing iPhone/iPad apps using SQLite Data and UITableView.



And now, the steps involved with the creation of outstanding iPhone/iPad apps using SQLite Data and UITableView

Step 1- Create a SQLite Database

With the ultimate perks of iPhone Application Development Services, you can use Firefox SQLite Manager addin for creating the SQLite database. You can name it as authorsDb.sqlite. Ensure to save it at a handy location as you'd need to copy it into the Xcode project via Xcode and Finder.



Step 2- Create the iOS project

As per the second step, you need to create a Single View project that would specifically target iPhones. Here, ensure the storyboard option has been enabled. After creating the iOS project, delete the View Controller and instead create a UITableViewController by dragging the same onto the Storyboard canvas.



Step 3- Create the AuthorVC UITableViewController

You can create the AuthorVC UITableViewCOntroller by simply selecting “Add New File” option within the menu. Opt for the UIViewController available under the Cocoa Touch node and on the succeeding page, enter the AuthorVC name in addition to changing the subclass to UITableViewController. One of the most crucial things that need to be kept in mind is that the iPad option should not be selected. So, once you're done with the creation of the AuthorVC Class, open the Storyboard and select the UITableView for adding the class to the Custom Class field in the Attributes Inspector.



Step 4- Create the Author Class

In order to create the Author class, you'd need to repeat the step 3 with only one exception that you should choose the Objective-C class template. Also, on the second page, you'd be required to enter the Author class name with the sub class being NSObject.



Step 5- Implement AuthorVC

As per this step, you'd need to add data to the UITableView. For this, simply open the header file and import the sqlite3.h header file in addition to declaring a sqlite3 variable. Also, don't forget to declare a NSMutableArray instance variable.

In case, you get some issues you may hire iPhone app programmers or simply, proceed the above procedure, create a method authorlist with a NSMutableArray return type. Save this file and open the AuthorVC implementation file. As the first step, simply add the sqlite3 library and author.h libs in the import section, followed by implementing the “theauthors” NSMutableArray with the help of @synthesize directive. After this, you'll be required to implement two methods viz: numberOfSectionsInTableView and numberOfRowsinSection. While the former one defines the number of sections, the latter one defines the number of rows per section.



Step 6- Configure the UITableViewCell

You'd need to use the cellForRowAtIndexPath method for configuring the UITableViewCell. Here, you'd need to first change the value of the “CellIdentifier” to the same name that you specified for the Cell prototype. After this, define the int variable for the rowIndex. Finally, define a new Author object and assign it at the rowIndex in the NSMutableArray. Complete the process by adding values to the cell.textLabel and cell.textDescription properties.



Conclusion

Packed with powerful features, UITableView actually offers you the flexibility of organizing and displaying data within web applications in the most efficient way. Being easy to work with, both, SQLite and UITableView serve as magic wands for storing and displaying app data.

Comments
avatar
Please sign in to add comment.