My First iPhone App, One Step at a Time – Part 1

I’ve recently started trying to learn how to create iPhone apps and 20 or so tutorials later I’m no better off then when I started. I could follow someone else’s instructions step by step but when I got to the end I had no idea what I had just done or how to reproduce it. So I decided to stop the tutorials and start my own app and just do one thing at a time and maybe this will help me learn in baby steps. I’m going to try and write it all down here for my documentation but maybe it might help someone else as well. So, here we go.

Part 1

Goal for this step: Read from a database and display the data in a UITableView

Let’s create a new project in Xcode and create a new Single View Application.



Once the project is created, click on the MainStoryboard.storyboard and delete the view controller created by the project. Then drag a new Table View Controller onto the storyboard.


Now go into the ViewController.h and change the ViewController to inherit from UITAbleViewController instead of UIViewController.

@interface ViewController : UITableViewController

Now go back to the storyboard and click on the view controller, then click on the Identity Inspector tab and make sure the class is set to ViewController.


Save the project and run. You should see an empty TableView.


Now its time to create the database. Download SQLite Manager for FireFox and create a very simple table. For now all the column are going to be text just to keep things simple.


Drag the database mySchedule.sqlite and drop it on Xcode. Be sure to select “copy” items into destination group’s folder.



Create a class for the database by clicking “file” on the menu and then “new” then “file”. Select the “Objective-C class” and select “next”.


Change MySchedule.h to look like below. Defining the pointers and properties of the table columns.

 @interface MySchedule : NSObject{ NSString *weekof; NSString *monday; NSString *tuesday; NSString *wednesday; NSString *thursday; NSString *friday; NSString *saturday; NSString *sunday; } @property(nonatomic, copy) NSString *weekof; @property(nonatomic, copy) NSString *monday; @property(nonatomic, copy) NSString *tuesday; @property(nonatomic, copy) NSString *wednesday; @property(nonatomic, copy) NSString *thursday; @property(nonatomic, copy) NSString *friday; @property(nonatomic, copy) NSString *saturday; @property(nonatomic, copy) NSString *sunday; @end 

Add “import sqlite3.h” to both ViewController.h and ViewController.m.

Create an NSMutableArray called scheduleArray to hold the data we will read from the database.

Create a method called scheduleList.

ViewController.h should look like this.




Set the identifier in the proptype cell to ScheduleCell so we can refer to it by name in our code


Now set the text of the table cells initial view in cellForRowAtIndexPath

Compile and Run and we have an app that displays dates from a database in a tableView.

Download the project files for Part 1 – MySchedule Part 1

One thought on “My First iPhone App, One Step at a Time – Part 1”

  1. MIchael H says:

    I got the same thing! Not. That is pretty latin to me. Keep going though!

Comments are closed.