for a simple hello world app it creates 4 files
HelloWorldAppDelegate.h
HelloWorldAppDelegate.m
MyViewController.h
MyViewController.m
HelloWorldAppDelegate.h
CODE
#import <UIKit/UIKit.h>
@class MyViewController;
@interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
MyViewController *myViewController;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) MyViewController *myViewController;
@end
HelloWorldAppDelegate.m
CODE
#import "HelloWorldAppDelegate.h"
#import "MyViewController.h"
@implementation HelloWorldAppDelegate
@synthesize window;
@synthesize myViewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Set up the view controller
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"HelloWorld" bundle:[NSBundle mainBundle]];
self.myViewController = aViewController;
[aViewController release];
// Add the view controller's view as a subview of the window
UIView *controllersView = [myViewController view];
[window addSubview:controllersView];
[window makeKeyAndVisible];
}
- (void)dealloc {
[myViewController release];
[window release];
[super dealloc];
}
@end
MyViewController.h
CODE
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController <UITextFieldDelegate> {
IBOutlet UITextField *textField;
IBOutlet UILabel *label;
NSString *string;
}
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UILabel *label;
@property (nonatomic, copy) NSString *string;
- (IBAction)changeGreeting:(id)sender;
@end
MyViewController.m
CODE
#import "MyViewController.h"
@implementation MyViewController
@synthesize textField;
@synthesize label;
@synthesize string;
- (IBAction)changeGreeting:(id)sender {
// Set our model value -- it's not used anywhere else at the moment, but it illustrates the principle
self.string = textField.text;
NSString *nameString = string;
// If the user entered an empty string, set the name string to "World"
if ([nameString length] == 0) {
nameString = @"World";
}
// Create a new string for the label
NSString *greeting = [[NSString alloc ] initWithFormat:@"Hello, %@!", nameString];
label.text = greeting;
/*
The greeting string was created with 'alloc', so to adhere to memory managment conventions, now release it. It's the label's responsibility to take ownership of the greeting string when its text is set.
*/
[greeting release];
}
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
// When the user presses return, take focus away from the text field so that the keyboard is dismissed.
if (theTextField == textField) {
[textField resignFirstResponder];
}
return YES;
}
- (void)dealloc {
// To adhere to memory management rules, release the instance variables.
[string release];
[textField release];
[label release];
[super dealloc];
}
@end
Thats basically it 4 files but there is a bug when run in the iPhone simulator I don't know what the cause is. Can anyone explain what file is run first and whats called etc. I still have no idea what one of the four files are executed first.

