Create an iphone application using xcode that dynamically creates sqlite tables

This tutorial will try to create an iphone application that will dynamically create tables in sqlite database. This tutorial will use anime information for example.

Note that this tutorial is not for beginner, I'll just summarized the steps and provide the github repository for the project.

Prerequisite:
1.) You should look at the code in my todo list tutorial before this one.
2.) Create an anime sqlite database using your preferred tool, I've used SQLite Manager plugin for firefox.

Steps:
1.) Create a new empty ios project.

2.) Select the project, and in the general tab under Linked Frameworks, add libsqlite3.0.dylib.

3.) Add the sqlite database we've created, right click on the project folder click Add Files..., then select the anime.sqlite file and check "Copy items into destination...". Now we have the database inside our project.
Your project should look like:

4.) Create the main story board inside the SqliteAnimeDb folder.

5.) In the project setting set the main interface to the story board we've created.

6.) Comment these 3 lines in the AppDelegate class:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

7.) I'll let the code explain but I'm attaching the 2 views I've created for demo.

In this view we display the list of anime titles with author subtitle. Clear and reload do the functions respectively on the database. + will navigate to the next view.


This view is where we add an anime object.

Note:
KBSSqliteConnection, is the class where we put the sqlite database operations like create table, open db, insert record, etc.

Github repository:

0 nhận xét:

Đăng nhận xét