Category Archives: Xcode

iOS start up procedures

iOS app structure

All apps have a main.m, which contains the app’s entry point, a function called main().

The main() function initializes an “application” object (you can think of this as the runtime environment for the app).

Then, in a typical configuration, the app’s main nib file is loaded. (The name of the nib file is seen in -Info.plist.)

The nib file loads, and by configuration, causes the application delegate to load. The application delegate implements methods that handle application-level events. Then, typically, the app’s initial view and view controller are initialized, and control is passed to the view controller.

After that, user interaction and other events in the environment will determine what happens next.

A typical app, therefore, has the following components (that make up its structure):

main() function, in main.m
configuration info located in -Info.plist
application delegate (AppDelegate.h and .m)
initial view (nib file) and view controller (.h and .m)
other views and view controllers
resources like images and so on
app icon, as a 57px square PNG-format image

iOS app startup

What is the typical startup sequence? What happens, and in what order? The following details the steps:

The app is launched by the user
The main() function is the entry point, and runs
The UIApplicationMain() function is called
The application (singleton) object is created (i.e. the runtime environment for the app)
-Info.plist is examined, and the nib file named in “Main nib file base name” is loaded (which means that all of its objects are initialized, and connections are established)
As part of the nib loading, the awakeFromNib: method is called on all the objects that it initialized
The runtime sends the applicationWillFinishLaunching: message to the application delegate
The nib’s File’s Owner object has an instance variable named “delegate”; the object that it points to is the application delegate, which is then initialized
The runtime sends the application:didFinishLaunchingWithOptions: message to the application delegate


Debugging Iphone Apps with a Real Iphone

IPhone Hello World Tutorial

One thing to add to the tutorial
Click Project>Edit Scheme and Change Iphone simulator to IPAD

HelloWorldViewController.h file:

// HelloWorldViewController.h
// HelloWorld
// Created by Paul Peelen on 2011-03-14.
// Copyright 2011 9697271014. All rights reserved.

// HelloWorldViewController.m
// HelloWorld
// Created by Paul Peelen on 2011-03-14.
// Copyright 2011 9697271014. All rights reserved.

#import “HelloWorldViewController.h”

@implementation HelloWorldViewController

@synthesize textLabel;

– (void)dealloc
[textLabel release];
[super dealloc];

– (IBAction)changeTheTextOfTheLabel
[textLabel setText:@”Hello, World!”];

– (void)didReceiveMemoryWarning
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.

#pragma mark – View lifecycle

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
[super viewDidLoad];

– (void)viewDidUnload
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;

– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);


@interface HelloWorldViewController : UIViewController {
UILabel *textLabel;

@property (nonatomic, retain) IBOutlet UILabel *textLabel;

– (IBAction)changeTheTextOfTheLabel;