IOS DevelopmentLec 2
Anatomy of an         ApplicationCompiled code   Your code   FrameworksNib files   UI elements and other objects   Details...
App Lifecycle
UIKit FrameworkStarts your applicationEvery application has a single instance of UIApplication   Singleton design pattern@...
DelegationControl passed to delegate objects to performapplication- specific behaviorAvoids need to subclass complex objec...
UIApplicationDelegateXcode project templates have one set up bydefaultObject you provide that participates in applicationl...
UIApplicationDelegate   Examples:-(void)applicationDidFinishLaunching:(UIApplication*)application;- (void)applicationWillT...
Info.plist fileProperty List (often XML), describing your application   Icon appearance   Status bar style (default, black...
MVC
Model, View, Controller             controller     model                view
ModelManages the app data and stateNot concerned with UI or presentationOften persists somewhereSame model should be reusa...
ViewPresent the Model to the user in an appropriateinterfaceAllows user to manipulate dataDoes not store any data   (excep...
ControllerIntermediary between Model & ViewUpdates the view when the model changesUpdates the model when the user manipula...
Demo
Interface Builder and         Nibs
Nib Files - Design timeHelps you design the „V‟ in MVC:   layout user interface elements   add controller objects   Connec...
Nib LoadingAt runtime, objects are unarchived    Values/settings in Interface Builder are restored    Ensures all outlets ...
Default empty implementation on NSObjectYou often implement it in your controller class   e.g. to restore previously saved...
Controls – EventsView objects that allows users to initiate some type ofactionRespond to variety of events   Touch events ...
DemoTarget/Action - event
Action Methods3 different flavors of action method selector types        nMethod:(id)sender withEvent:(UIEvent *)event;UIE...
Action Method Variations     Simple no-argument selector     Single argument selector - control is „sender‟//
Action Method Variations Two-arguments in selector (sender & event)
Multiple target-actionsControls can trigger multiple actions on differenttargets in response to the same eventDifferent th...
Manual Target-ActionSame information IB would useAPI and UIControlEvents found in UIControl.hUIControlEvents is a bitmask
Ios development 2
Upcoming SlideShare
Loading in …5
×

Ios development 2

455 views

Published on

taken from Stanford CS193P Winter 2010

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
455
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • UIControlEventTouchUpInside-(void)decrease
  • Ios development 2

    1. 1. IOS DevelopmentLec 2
    2. 2. Anatomy of an ApplicationCompiled code Your code FrameworksNib files UI elements and other objects Details about object relationshipsResources (images, sounds, strings, etc)Info.plist file (application configuration)
    3. 3. App Lifecycle
    4. 4. UIKit FrameworkStarts your applicationEvery 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
    5. 5. DelegationControl passed to delegate objects to performapplication- specific behaviorAvoids need to subclass complex objectsMany UIKit classes use delegates UIApplication UITableView UITextField
    6. 6. UIApplicationDelegateXcode project templates have one set up bydefaultObject you provide that participates in applicationlifecycleCan implement various methods whichUIApplication will call
    7. 7. UIApplicationDelegate Examples:-(void)applicationDidFinishLaunching:(UIApplication*)application;- (void)applicationWillTerminate:(UIApplication *)application;- (void)applicationWillResignActive:(UIApplication *)application;-(BOOL)application:(UIApplication *)applicationhandleOpenURL:(NSURL *)url;- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application;
    8. 8. Info.plist fileProperty List (often XML), describing your application Icon appearance Status bar style (default, black, hidden) Orientation Uses Wifi networking System RequirementsCan edit most properties in XcodeProject > Edit Active Target “Foo” menu itemOn the properties tab
    9. 9. MVC
    10. 10. Model, View, Controller controller model view
    11. 11. ModelManages the app data and stateNot concerned with UI or presentationOften persists somewhereSame model should be reusable, unchanged indifferent interfaces
    12. 12. ViewPresent the Model to the user in an appropriateinterfaceAllows user to manipulate dataDoes not store any data (except to cache state)Easily reusable & configurable to display differentdata
    13. 13. ControllerIntermediary between Model & ViewUpdates the view when the model changesUpdates the model when the user manipulatesthe viewTypically where the app logic lives.
    14. 14. Demo
    15. 15. Interface Builder and Nibs
    16. 16. Nib Files - Design timeHelps you design the „V‟ in MVC: layout user interface elements add controller objects Connect the controller and UI
    17. 17. Nib LoadingAt runtime, objects are unarchived Values/settings in Interface Builder are restored Ensures all outlets and actions are connected Order of unarchiving is not definedIf loading the nib automatically creates objects and order isundefined, how do I customize? For example, to displaying initial state -awakeFromNibControl point to implement any additional logic after nibloading
    18. 18. Default empty implementation on NSObjectYou often implement it in your controller class e.g. to restore previously saved application stateGuaranteed everything has been unarchivedfrom nib, and all connections are made before -awakeFromNib is called
    19. 19. Controls – EventsView objects that allows users to initiate some type ofactionRespond to variety of events Touch events touchDown touchDragged (entered, exited, drag inside, drag outside) touchUp (inside, outside) Value changed Editing events editing began editing changed editing ended
    20. 20. DemoTarget/Action - event
    21. 21. Action Methods3 different flavors of action method selector types nMethod:(id)sender withEvent:(UIEvent *)event;UIEvent contains details about the event that took place
    22. 22. Action Method Variations Simple no-argument selector Single argument selector - control is „sender‟//
    23. 23. Action Method Variations Two-arguments in selector (sender & event)
    24. 24. Multiple target-actionsControls can trigger multiple actions on differenttargets in response to the same eventDifferent than Cocoa on the desktop where onlyone target- action is supportedDifferent events can be setup in IB
    25. 25. Manual Target-ActionSame information IB would useAPI and UIControlEvents found in UIControl.hUIControlEvents is a bitmask

    ×