Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to iOS Software Development (OOP 2011)

Introduction to iOS Software Development (OOP 2011)

Presentation given during OOP 2011, Münich, Germany.

Adrian Kosmaczewski

January 26, 2011
Tweet

More Decks by Adrian Kosmaczewski

Other Decks in Technology

Transcript

  1. Introduction to iOS
    Software Development
    Adrian Kosmaczewski - akosma software
    OOP 2011

    View Slide

  2. Adrian Kosmaczewski

    View Slide

  3. http://www.flickr.com/photos/gi/164281467/

    View Slide

  4. http://www.flickr.com/photos/jm3/379494322/

    View Slide

  5. http://www.flickr.com/photos/21025851@N00/2168398185/

    View Slide

  6. http://www.flickr.com/photos/emiliagarassino/2146648332/

    View Slide

  7. akosma software

    View Slide

  8. akosma.com
    github.com/akosma
    linkedin.com/in/akosma
    formspring.me/akosma
    twitter.com/akosma
    slideshare.com/akosma

    View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. iOS

    View Slide

  13. http://www.flickr.com/photos/oskay/365607662/

    View Slide

  14. http://www.flickr.com/photos/oskay/365607591/

    View Slide

  15. http://www.flickr.com/photos/blakespot/2379207825/

    View Slide

  16. http://www.flickr.com/photos/justdrew1985/4348527596/

    View Slide

  17. View Slide

  18. Some questions

    View Slide

  19. iOS devices in the
    room?

    View Slide

  20. Veteran NeXT or Mac
    OS X developers in
    the room?

    View Slide

  21. View Slide

  22. Program
    History
    Objective-C
    Cocoa
    Tools
    Web vs. Native Apps
    The App Store
    Design
    Books
    Q&A

    View Slide

  23. View Slide

  24. History

    View Slide

  25. “Good design
    survives”
    Erich Gamma
    OOP 2011 Keynote

    View Slide

  26. born in the 80s

    View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. View Slide

  31. View Slide

  32. Objective-C

    View Slide

  33. "Thin layer around C"
    Message-dispatch runtime built on C
    obj_msgSend()
    Static and dynamic (you choose)
    The “real” inspiration for Java:
    http://cs.gmu.edu/~sean/stuff/java-objc.html

    View Slide

  34. Single inheritance + interfaces (“@protocols”)
    @protocols can have @optional methods
    Fields protected by default
    All methods are public, virtual and overridable
    Methods can be added to existing classes ("categories")
    Full introspection / reflection
    Messages can be intercepted and forwarded à la AOP

    View Slide

  35. Objective-C Java
    @interface (.h) &
    @implementation (.m)
    class (1 file)
    @protocol interface
    #import // files! import // classes!
    categories n/a (C#, “class extensions”)
    id
    n/a (generics?)
    "void*"

    View Slide

  36. Objective-C Java / C#
    @selector
    n/a
    (C# delegates)
    NSObject / NSProxy / ... Object
    @public / @protected /
    @private
    public / protected / private
    @try / @catch / @finally
    NSException
    try / catch / finally
    Exception
    n/a package / namespace

    View Slide

  37. Classes

    View Slide

  38. extends
    class

    View Slide

  39. Methods

    View Slide

  40. Syntax inspired from
    Smalltalk

    View Slide

  41. void insertObject(anObject, index)

    View Slide

  42. aName.copy()
    this.alloc().initWithString(aName).autorelease()

    View Slide

  43. Memory Management

    View Slide

  44. iPhone 3G: 128 MB RAM
    iPhone 3GS, iPad: 256 MB RAM
    iPhone 4: 512 MB RAM

    View Slide

  45. ±70 MB for the OS!

    View Slide

  46. no swap file

    View Slide

  47. (no virtual memory)

    View Slide

  48. http://www.flickr.com/photos/cheek/699407283/

    View Slide

  49. no garbage collection

    View Slide

  50. objects have a
    “retain count”

    View Slide

  51. http://cocoadevcentral.com/d/learn_objectivec/

    View Slide

  52. basic rule:

    View Slide

  53. for every
    [alloc], [retain], [copy]
    there must be a
    [release]

    View Slide

  54. beware:

    View Slide

  55. Objective-C only allows
    objects on the heap

    View Slide

  56. http://linguiniontheceiling.blogspot.com/2008/10/thats-madame-trash-heap-to-you.html

    View Slide

  57. No automatic objects
    on the stack (C++)

    View Slide

  58. http://www.futuregov.net/photologue/photo/2008/aug/30/stack-papers/

    View Slide

  59. // C++
    // Memory freed when out of scope
    std::string name(“Adrian”);
    std::string *name = NULL;
    name = new std::string(“Adrian”);
    delete name;

    View Slide

  60. iOS memory warnings

    View Slide

  61. View Slide

  62. http://www.flickr.com/photos/tbuser/2763035540/

    View Slide

  63. http://akosma.com/2009/01/28/10-iphone-memory-management-tips/

    View Slide

  64. http://akosma.com/2009/07/16/objective-c-compiler-warnings/

    View Slide

  65. View Slide

  66. Cocoa

    View Slide

  67. View Slide

  68. UIKit

    View Slide

  69. View Slide

  70. View Slide

  71. Tools

    View Slide

  72. Xcode
    Interface Builder

    View Slide

  73. View Slide

  74. Shark

    View Slide

  75. View Slide

  76. View Slide

  77. View Slide

  78. Instruments

    View Slide

  79. View Slide

  80. View Slide

  81. View Slide

  82. Clang Static Analyzer

    View Slide

  83. http://llvm.org/

    View Slide

  84. http://clang-analyzer.llvm.org/

    View Slide

  85. View Slide

  86. Source: Apple Documentation

    View Slide

  87. Source: Apple Documentation

    View Slide

  88. Source: Apple Documentation

    View Slide

  89. Source: Apple Documentation

    View Slide

  90. View Slide

  91. Web or native apps?

    View Slide

  92. update frequency
    usage frequency
    UI complexity
    native
    apps
    web
    apps
    stocks
    calculator
    business forms
    reports

    View Slide

  93. Web Application Native SDK Application
    Pros
    Simpler deployment and
    updates;
    known technologies,
    cheaper to maintain;
    access to GPS information;
    basic offline support.
    Faster execution;
    access to address book,
    accelerometer, audio and
    camera;
    3D games and animations;
    push notifications;
    Bonjour networking support.
    Cons
    Slower to execute;
    no access to hardware.
    App Store review process;
    longer update times.

    View Slide

  94. Sencha Touch
    iUI
    jQTouch
    WebApp.net
    XUI
    Rhodes
    SproutCore
    Cappuccino
    LiquidGear
    PhoneGap
    Safire
    jPint
    Magic Framework

    View Slide

  95. Also remember

    View Slide

  96. Not all WebKits
    are made equal

    View Slide

  97. WebKit Compatibility
    Table
    http://www.quirksmode.org/webkit.html

    View Slide

  98. View Slide

  99. Native apps
    advantages

    View Slide

  100. 1
    offline
    web catching up!

    View Slide

  101. 2
    location services
    web catching up!

    View Slide

  102. 3
    camera

    View Slide

  103. 4
    audio & 3D

    View Slide

  104. 5
    accelerometer &
    gyroscope
    web catching up!

    View Slide

  105. 6
    notifications

    View Slide

  106. http://www.flickr.com/photos/epitti/2565572445/

    View Slide

  107. 7
    monetization!

    View Slide

  108. Native components

    View Slide

  109. Address Book
    ABAddressBook
    ABMultiValue
    ABMutableMultiValue
    ABRecord
    ABGroup
    ABPerson
    http://www.flickr.com/photos/kevinmarsh/2315151843/

    View Slide

  110. Accelerometer
    UIAccelerometer UIAccelerometerDelegate
    http://www.flickr.com/photos/evert-jan/2784525711/
    http://www.flickr.com/photos/evert-jan/2785380754/

    View Slide

  111. Video
    MPMoviePlayerController
    http://www.flickr.com/photos/pingping/1431127181/

    View Slide

  112. Location services
    CLLocation
    CLLocationManager
    http://www.flickr.com/photos/thomcochrane/2780365916/

    View Slide

  113. Graphics & Animation
    CALayer
    CAAnimation
    UIGraphicsContext
    CGRect / CGMakeRect
    UIBezierPath
    UIColor
    http://www.flickr.com/photos/alleus/2905293514/

    View Slide

  114. Camera & Photo Library
    UIImagePickerController
    UIImagePickerControllerDelegate
    UIImagePickerControllerSourceTypeCamera
    UIImagePickerControllerSourceTypePhotoLibrary
    http://www.flickr.com/photos/ernohannink/2713579416/

    View Slide

  115. And More
    Audio
    XML
    WebKit
    SQLite / Core Data
    Networking
    Bonjour
    Bluetooth / GameKit
    AirPrint
    iCal (EventKit)
    AirPlay
    Compass
    Gyroscope
    Gestures
    Core Text

    View Slide

  116. View Slide

  117. Other languages?
    Cross-platform?

    View Slide

  118. http://akosma.com/2009/10/29/iphone-apps-without-objective-c/

    View Slide

  119. View Slide

  120. The App Store
    in 5 steps

    View Slide

  121. 1. Register

    View Slide

  122. http://developer.apple.com/programs/iphone/

    View Slide

  123. 2. Develop

    View Slide

  124. View Slide

  125. 3. Publish

    View Slide

  126. View Slide

  127. Requirements
    Free apps: nothing
    Paying apps:
    EIN Number, via IRS
    Bank account

    View Slide

  128. 4. Approval

    View Slide

  129. View Slide

  130. 4.1 Rejection

    View Slide

  131. “Your application cannot be posted to the App Store at
    this time because it does not adhere to the iPhone
    Human Interface Guidelines as outlined in iPhone SDK
    Agreement section x.x.x.
    When the device is in this or that condition, the
    application does not do this or that. This behavior
    might lead to user confusion. It would be appropriate
    to display either a notification or an alert stating that
    such or such condition is required.
    In order for your application to be reconsidered for the
    App Store, please resolve this issue and upload your
    new binary to iTunes Connect.”

    View Slide

  132. 5. Sales

    View Slide

  133. https://itunesconnect.apple.com/

    View Slide

  134. View Slide

  135. View Slide

  136. Honor the Mobile Human
    Interface Guidelines

    View Slide

  137. http://developer.apple.com/iphone/library/documentation/
    userexperience/conceptual/mobilehig/

    View Slide

  138. View Slide

  139. avoid this

    View Slide

  140. http://www.flickr.com/photos/gruber/2635257578/

    View Slide

  141. and this

    View Slide

  142. http://smokingapples.com/iphone/app-store-iphone/the-worst-twitter-client-ever/

    View Slide


  143. I can’t find one redeeming quality about this app. It’s slow to start [on a
    3GS], doesn’t respond to taps while it’s trying to load other things, and
    crashes if you try to change modes a lot. It’s limited to only timeline,
    replies, and messages. It has no other functionality. Oh wait… I forgot its
    killer feature, you can have custom backgrounds and choose the color of
    your tweets. That totally makes up for its lack of useful features and
    sluggish performance. I’m not sure why someone would bother building
    such an inferior app other than that they wanted to find some suckers and
    score a quick buck. It seems even more insane to me that they’d be
    actively seeking out reviewers to cover this. I was given a promo code for
    ChillTwit, and even for free I didn’t want it on my phone. I was sad just
    from looking at screenshots. Actually seeing it running confirmed all of my
    fears. If it was a free app, I might forgive the developer, but the fact that
    he’s trying to get $0.99 out of people pisses me off to no end. Go buy
    Tweetie.
    If you somehow weren’t scared away by all my bitching and whinning, you
    can see ChillTwit on the app store here. But seriously, if you buy this,
    we’re not friends anymore.

    View Slide

  144. View Slide

  145. Books

    View Slide

  146. View Slide

  147. View Slide

  148. View Slide

  149. View Slide

  150. View Slide

  151. View Slide

  152. View Slide

  153. View Slide

  154. View Slide

  155. View Slide

  156. View Slide

  157. View Slide

  158. View Slide

  159. Thanks!

    View Slide

  160. Questions?

    View Slide

  161. Created and edited on Keynote for iPad
    Copyright 2011 (c) akosma software
    All Rights Reserved.

    View Slide