资源预览内容
第1页 / 共59页
第2页 / 共59页
第3页 / 共59页
第4页 / 共59页
第5页 / 共59页
第6页 / 共59页
第7页 / 共59页
第8页 / 共59页
第9页 / 共59页
第10页 / 共59页
亲,该文档总共59页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
CS193P - Lecture 4 iPhone Application Development Building an Application Model, View, Controller Nib Files Controls and Target-Action 1Friday, January 15, 2010 Announcements Friday sections Friday, 4-5: 260-113 Invites to Developer Program will go out this weekend Sign up and get your certificate when you get it Start making apps that will run on Hardware! Waiting for a couple students to reply about P/NC spots If we dont hear back today, were giving them away 2Friday, January 15, 2010 Todays Topics Application Lifecycle Model, View, Controller design Interface Builder and Nib Files Controls and Target-Action HelloPoly demo 3Friday, January 15, 2010 Review 4Friday, January 15, 2010 Memory Management Alloc/Init -alloc assigns memory; -init sets up the object Override -init, not -alloc Retain/Release Increment and decrement retainCount When retainCount is 0, object is deallocated Dont call -dealloc! Autorelease Object is released when run loop completes 5Friday, January 15, 2010 Setters, Getters, and Properties Setters and Getters have a standard format: - (int)age; - (void)setAge:(int)age; Properties allow access to setters and getters through dot syntax: property age; int theAge = person.age; person.age = 21; 6Friday, January 15, 2010 Building an Application 7Friday, January 15, 2010 Anatomy of an Application Compiled code Your code Frameworks Nib files UI elements and other objects Details about object relationships Resources (images, sounds, strings, etc) Info.plist file (application configuration) 8Friday, January 15, 2010 App Lifecycle Launch app Load main nib Wait for event Handle event Exit app App initialized 9Friday, January 15, 2010 UIKit Framework Provides standard interface elements UIKit and you Dont fight the frameworks Understand the designs and how you fit into them 10Friday, January 15, 2010 UIKit Framework Starts your application Every application has a single instance of UIApplication Singleton design pattern interface UIApplication + (UIApplication *)sharedApplication end Orchestrates the lifecycle of an application Dispatches events Manages status bar, application icon badge Rarely subclassed Uses delegation instead 11Friday, January 15, 2010 Delegation Control passed to delegate objects to perform application- specific behavior Avoids need to subclass complex objects Many UIKit classes use delegates UIApplication UITableView UITextField 12Friday, January 15, 2010 Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: UIApplicationDelegate 13Friday, January 15, 2010 Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationDidFinishLaunching:(UIApplication *)application; - (void)applicationWillTerminate:(UIApplication *)application; UIApplicationDelegate 13Friday, January 15, 2010 Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationWillResignActive:(UIApplication *)application; - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url; - (void)applicationDidFinishLaunching:(UIApplication *)application; - (void)applicationWillTerminate:(UIApplication *)application; UIApplicationDelegate 13Friday, January 15, 2010 Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application; - (void)applicationWillResignActive:(UIApplication *)application; - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url; - (void)applicationDidFinishLaunching:(UIApplication *)application; - (void)applicationWillTerminate:(UIApplication *)application; UIApplicationDelegate 13Friday, January 15, 2010 Info.plist file Property List (often XML), describing your application Icon appearance Status bar style (default, black, hidden) Orientation Uses Wifi networking System Requirements Can edit most properties in Xcode Project Edit Active Target “Foo” menu item On the properties tab 14Friday, January 15, 2010 Model, View, Controller If you take nothing else away from this class. 15Friday, January 15, 2010 Model, View, Controller ModelView Controller 16Friday, January 15, 2010 Model Manages the app data and state Not concerned with UI or presentation Often persists somewhere Same model should be reusable, unchanged in different interfaces 17Friday, January 15, 2010 View Present the Model to the user in an appropriate interface Allows user to manipulate data Does not store any data (except to c
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号