iPhone Programming [7/17] : Behind the Scene

  • 2,528 views
Uploaded on

Presentation for developing iPhone Applications

Presentation for developing iPhone Applications

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,528
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
9

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Behind The Scenes Dr. Thanisa Kruawaisayawan www.imcinstitute.com
  • 2. Behind The Scene: HelloWorld (Single View Application)• ViewController is the File’s Owner of ViewController.xib. File’s Owner represents the object that loaded the nib file from disk and owns this copy of the nib file. 2
  • 3. Behind The Scene: HelloWorld (Single View Application)• ViewController has a view linked to View 3
  • 4. Revisit: iOS Application Life Cycle Souce: http://developer.bada.com/article/A-Comparison-between-iOS-and-bada-Application-Development-Part1 4
  • 5. main() => UIApplicationMain() • principalClassName • Pass nil when you have no UIApplication subclasses • delegateClassName • Pass a custom class that implements UIApplicationDelegate protocol 5
  • 6. AppDelegate.h• This class implements UIApplicationDelegate Protocol.• AppDelegate is the delegate of UIApplication object.• AppDelegate has two properties (named “window”, and “viewController”) which are instance of UIWindow and ViewController 6
  • 7. AppDelegate.m• UIWindow has a property named “rootViewController”, which is now pointed to viewController object. 7
  • 8. Behind The Scene 8
  • 9. Behind The Scene window(in AppDelegate) viewController view = 9
  • 10. Behind The Scene: HelloWorld_Storyboard• ViewController is the File’s Owner of MainStoryboard.storyboard. 10
  • 11. Behind The Scene: HelloWorld_Storyboard• ViewController has a view linked to View 11
  • 12. AppDelegate.h• AppDelegate has two properties (named “window”) which are instance of UIWindow. 12
  • 13. AppDelegate.m 13
  • 14. HelloWorld_Storyboard-Info.plist 14
  • 15. Behind The Scene window(in AppDelegate) viewController view = 15
  • 16. Model-View-Controller (MVC) Design Pattern 16
  • 17. Model-View-Controller (MVC) Design Pattern• Model (any data in your program) Are separated in such a manner that modifying either the view or• View (what the user sees) model component of your program has no effect on one• Controller (a layer that handles another.  all interaction between the view and model) 17
  • 18. What Files Are In The Project?• Source Files • AppDelegate.h & AppDelegate.m Controller • ViewController.h & ViewController.m View • ViewController.xib / MainStoryboard.storyboard• Supporting Files • HelloWorld-Info.plist • main.m 18
  • 19. New an Empty Application 19
  • 20. HelloWorldEmptyWindow 20
  • 21. AppDelegate.h• AppDelegate has two properties (named “window”) which are instance of UIWindow. 21
  • 22. AppDelegate.m• Window becomes the Key window and is Visible to the screen 22
  • 23. Run and See Result• This is a window with white background. 23
  • 24. AppDelegate.m• Add a label into the window 24
  • 25. Run and See Result 25
  • 26. New File > Window > MainWindow.xib 26
  • 27. MainWindow.xib• Set File’s Owner of MainWindow.xib to Class: UIApplication 27
  • 28. MainWindow.xib• Drag and drop Object 28
  • 29. MainWindow.xib• Set Object to Class: AppDelegate 29
  • 30. MainWindow.xib• Right click at File’s Owner• Link delegate to App Delegate 30
  • 31. AppDelegate.h• Add IBOutlet in front of UIWindow 31
  • 32. AppDelegate.m• Comment codes 32
  • 33. MainWindow.xib• Right click at App Delegate• Link window to Window 33
  • 34. MainWindow.xib• Drag and drop Label and change text into Hello World 34
  • 35. HelloWorldEmptyWindow-Info.plist• Add Row > Key: Main nib file base name and Value: MainWindow 35
  • 36. Launch the Application 36
  • 37. Run and See Result 37
  • 38. Conclusion for HelloWorldEmptyWindow• Create a new xib file • Goto AppDelegate.h and put New File -> Window -> IBOutlet in front of UIWindow MainWindow.xib *window;• Click at Files Owner of • Goto Window.xib again and MainWindow.xib -> change this connect window under Outlets to class to UIApplication Window• Drag and drop an Object under Objects -> select the third tab on • Also in plist file add a row the right -> change this class to Key: Main nib file base name AppDelegate Type: String• Right click at File’s Owner and Value: MainWindow connect delegate to App Delegate 38
  • 39. MainWindow.xib• Drag and drop Round Rect Button and change text into Say Hello Where to write action code? 39
  • 40. New an Empty Application 40
  • 41. HelloWorldEmptyViewController 41
  • 42. New File > Objective-C class• Apple calls the library to develop UI in iPhone as Cocoa Touch and in Mac as Cocoa. 42
  • 43. ViewController• Enter Class: ViewController, choose Subclass of UIViewController, and select With XIB for user interface 43
  • 44. ViewController.xib• File’s Owner of ViewController.xib is Class: ViewController 44
  • 45. ViewController.xib• Drag and drop label (delete text) 45
  • 46. ViewController.xib• Drag and drop Round Rect Button (change text to “Say Hello”) 46
  • 47. ViewController.xib to ViewController.h• Control + Drag from the label in ViewController.xib to ViewController.h 47
  • 48. ViewController.xib to ViewController.h• Control + Drag from the button in ViewController.xib to ViewController.h 48
  • 49. ViewController.m• Add code in sayHello method 49
  • 50. AppDelegate.h• Add codes 50
  • 51. AppDelegate.m• Add codes 51
  • 52. Run and See Result 52
  • 53. Revisit: New File > Objective-C class > ViewController• Enter Class: ViewController, choose Subclass of UIViewController, and forget to select With XIB for user interface 53
  • 54. New File > View > ViewController1.xib 54
  • 55. ViewController1.xib• Change File’s Owner of ViewController1.xib to Class: ViewController and Link view of ViewController to View 55
  • 56. ViewController1.xib• Drag and drop Label and change text to ViewController1 56
  • 57. AppDelegate.m• Change from ViewController to ViewController1 for initWithNibName 57
  • 58. Run and See Result 58
  • 59. References• Boonyanit Mathayomchan, Ph.D., “iPhone Application Development (BASIC)”, 2011• Chotipat Pornavalai, iPhone Basic #1, Mini Master of iOS Application #1• Dave Mark, et.al, “Beginning iOS5 Development: Exploring the iOS SDK”, 2012• Joe Conway & Aaron Hillegass, “iPhone Programming: The Big Nerd Ranch Guide”, 2010 59