Creation of the first iPhone application
The first iPhone application discussed in this article has been created in the following article:
Creation of First iPhone application explained
This project is a simple navigation-based application. It uses a table view on the main window. From the code side, a table view controller (UITableViewController) is used to provide the functionality for a table based view.
The article below explains the actual source files for the above project. Links to the detailed articles on each source piece (main method and classes) are also provided.
The Source Code Files
For this project, we see three sets of source code files:
- App Delegate
- View Controller
Figure 1. The source code files that you would change in this project. You would change the app delegate and controller class source files directly. The user interface files are manipulated via Interface Builder.
The Objective-C file main.m contains the main method. This is where the program starts.
For this project (the program named FirstApp), the App Delegate class is created in the files FirstAppAppDelegate.h and FirstAppDelegate.m. This is where the application (from the Cocoa Touch perspective) starts and terminates. The start method is applicationDidFinishLaunching and the termination method is applicationWillTerminate (meaning, these are the methods where the developer can put the code that gets executed right after the launch and right before the termination). This class holds the window and the navigation controller at the top of the window.
This application (FirstApp) has one view. The controller for that view is in the following files: RootViewController.h and RootViewController.m. The main view of this application is a table. Hence, this class is based on the table view controller (UITableViewController).
The Class Model Diagram
Following is the Class Model Diagram for the App Delegate and View Controller classes. You can generate this class model diagram by using the Design - Class Model menu item.
Figure 2. The Class Diagram for the iPhone application named FirstApp. Here the custom classes point towards built-in classes and a protocol. The application delegate implements UIApplicationDelegate protocol and the main view is based on UITableViewController.
As you can see from the class diagram, there are two classes in this application: FirstAppAppDelegate and RootViewController.
The solid lines from these classes point to their base classes. FirstAppAppDelegate is derived from NSObject and RootViewController is derived from the class UITableViewController. The classes NSObject and UITableViewController are from the Cocoa Touch framework.
The dashed line from FirstAppAppDelegate points to UIApplicationDelegate, which is a protocol. This means, the FirstAppAppDelegate will implement some methods from the UIApplicationDelegate protocol. In this case, these two methods are applicationDidFinishLaunching and applicationWillTerminate.
Explanation for the Source Code
These individual source files and classes (main, application delegate, and the view controller) are explained in detail in the following articles:
Understanding a Typical main Method in Objective-C for iPhone Development
Application Delegate for the First iPhone Application Explained
View Controller for the First iPhone Application Explained