![]() ![]() This is good practice because by keeping everything abstracted, it makes it easier to switch to another storage method if we wanted to in the future. Next we’re going to create a helper class to handle all of the interaction with our sqlite3 database. We’re just creating a class to store the few pieces of data we’ll be displaying in our table view, and make a convenience constructor. [super is pretty standard Objective-C – there should be no surprises here. #import uniqueId = name = city = state = _state State:(NSString replace FailedBankInfo.m with the following: (id)initWithUniqueId:(int)uniqueId name:(NSString *)name city:(NSString *)city NSString (nonatomic, assign) int (nonatomic, copy) NSString (nonatomic, copy) NSString (nonatomic, copy) NSString *state Replace FailedBankInfo.h with the following: ![]() So let’s create a class to store this:Ĭlick on Classes and click “File\New File…”, choose “Cocoa Touch Class” on the side, pick “Objective-C class”, select “Subclass of NSObject”, and click “Next”. Rather than retrieving all of the data from the database, we’re just going to pull out the specific subset we need to display the first table view to save memory. Tapping on a bank in the table view should bring up another view with details on that bank. ![]() The first will show a list of banks in a table view. We’re going to have two screens for our app. Right click on Resources, click “Add\Existing Files…”, browse to where your banklist.sqlite3 file is saved, make sure “Copy items to destination group’s folder (if needed)” is checked, and click Add. Next, add in the database file that we created last time. Right click on Frameworks, click “Add\Existing Frameworks…”, and select “libsqlite3.dylib” from the dropdown. Then let’s link in the sqlite3 framework. Start by creating a new project in XCode using the Window-based Application template, and name the project FailedBanks. This time, we will cover how to make an iPhone app that reads data from the SQLite database we created, and display data in a table view and a drill down detail view. In the first part of the series, we talked about what SQLite is and why we’d want to use it, how to use the sqlite3 command-line utility, and how to import data programatically via Python. This is the second part of a two-part series where we show how to make an app that displays a list of failed US banks from a SQLite database. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |