Build an application Tutor : Michael Pan
Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist -
UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication sharedapplication]
Delegation - ( ) <UIApplicationDelegate>
Delegation - Animation A B Work for awhile A B
Delegation - Code A B @interface A{ B* delegate; } -(void) passtob; @end @implementation A -(void) passtob{ [delegate atctionofb]; } @end A * a = [A new] ; B * b = [B new]; a.delegate = b; [a passtob]
UIApplicationDelegate - (void)applicationdidreceivememorywarning: (UIApplication *)application; - (void)applicationwillresignactive: (UIApplication *)application; - (BOOL)application:(UIApplication *)application handleopenurl:(nsurl *)url; - (BOOL)application:(UIApplication *)application didfinishlaunchingwithoptions: (NSDictionary *)launchoptions - (void)applicationwillterminate: (UIApplication *)application;
or
Window-based
Save
Xcode
<UIApplicationDelegate> UIApplication Project Navigator
Main XIB
main.m #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retval = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retval; }
UIApplicationMain int UIApplicationMain ( int argc, char *argv[], NSString *principalclassname, NSString *delegateclassname ); argc argv main argv main principalclassname UIApplication Class name nil UIApplication delegateclassname application Class name principalclassname UIApplication application-delegate nil main nib ( ios xib MainWindow.xib )
MainWindow.xib UIWindow
IB - AppDelegate
- UIWindow
Model, View, Controller
MVC Design Pattern Controller Model View
View
Model View
Controller Model View View Model View
Controller CPU Model View Memory, DISK Monitor
Interface Builder
Xib or Nib files V in MVC model Controller
Load nib or xib file Object value / setting IBAction IBOutlet
xib Loading controller -awakefromnib -awakefromnib xib connection xib
Demo - awakefromnib
Target, Action & Event
Event-Event Handler View Event target - event handler target action Event Touch Value change Editing
Event, Target/Action Event occurs target : myobject action : @selector(print) event : TouchUpInside @interface MyController { } -(void) print; @end Event Handler
Action methods (void)actionmethod; // event event - (void)actionmethod:(id)sender; // event event - (void)actionmethod:(id)sender withevent:(uievent *)event // event
Example -(void) valuechanged:(id) sender { value = [sender value]; }
Multiple target-action Event target action Desktop Cocoa target-action IB
@interface UIControl - (void)addtarget:(id)target action:(sel)action forcontrolevents: (UIControlEvents)controlEvents; - (void)removetarget:(id)target action:(sel)action forcontrolevents: (UIControlEvents)controlEvents; @end
UI - Components UIView UIControl UIButton UISlider
Target, Action & Event
Review - Xcode & Interface Builder
Oh! Xcode
Xcode Control +
Project
Xcode
Simulator
Xib
Oh! Interface Builder
Inspector & Library Inspector Library
Document Window
File s Owner
Command + S : Command
Xcode
Hello iphone App
Templates for game 3D Model Basic With Controller and View
View-Based Project Project name Source Codes Project Configuration
Entry Point ProjectName+AppDelegate.m
UI Layout
Interface Builder
View
Build and Go - XCode
Console Console
Recap
String in Objective-C @ this is a string not string in c or c++
NSLog() printf() %d : %f : %@ : objectiv-c string NSLog(@ My name is %@, i am %d years old, @ Michael, 5);
Set Break Point enable disable
Demo Break Point
Recap
Simulator Simulate Single Finger Tap Drag Two Fingers Zoom in/out (click + alt) Move (click + alt + shift)
Simulator - Support 1 command + command + control + command + Z command + L shift + command + H Tap( ) Touch and Hold ( ) Double Tap ( ) Swipe ( ) Flick ( ) click Double Click
Simulator - Support 2 Drag Pinch Option Touch shift Pinch Option Core Location Xcode Simulator icon icon icon Home Button Reset Content and Setting 122.0307 37.3317 Apple 100 System Sound Service AvAudioPlayer MPMoviePlayerController
Demo Simulator
Questions?