1 of 11

iOS Development for Non-Engineers

Jeremy Bridon

Core S2 - Core Software Solutions

www.cores2.com

2 of 11

What you really need

  • Macintosh
  • Dev. License
  • XCode (4+)
  • iOS SDK (bundled with XCode)
  • Device (good for hardware testing)

3 of 11

Language & Framework:

intimate relationship

  • Development Language: C and Objective-C
    • Note: C++ is "supported"
  • Framework?
    • Base: NSObject, NSString, etc.
    • Features: Foundation, UIKit, CoreAnimation, etc.
  • What you should know:
    • Obj-C design implications
    • View hiarchy, UIView, UIViewController
    • Protocols & Delegates

4 of 11

Caveats of Objective-C

  • It is a PURE extension of C, unlike C++
  • Member-function calls are the same, conceptually
    • C++: int Data = MyObj.GetData()
    • ObjC: int Data = [MyObj GetData];
  • Argument list is more verbose
    • C++: MyFunc(a, b, c);
    • ObjC: [MyFunc: a withB: b withC: c];
  • All objects are on the heap
  • Protocols / delegates!

5 of 11

Protocols & Delegates

  • Preview: Similar to C callback functions / function pointers

6 of 11

View-Hierarchy

  • Views are built as a tree-graph (pyramid)
  • Roots are generally UIViewController
    • Globally: all owned by UIWindow (one per application)
    • Is essentially a container
  • Sub-objects derive from UIView
    • Caveat: Everything is rendered, these aren't "windows" of views
    • Can have custom-rendering, by overloading "renderFrame" member-function

7 of 11

View-Hierarchy

8 of 11

Demo!

View with sub-views

9 of 11

Protocols & Delegates

  • GUI commonly needs pseudo-asynchronous event callbacks
    • If user presses button, why should the OS block?
  • Some call-backs are specialized, giving back specific data types
    • Button's "ButtonPressed..." is different than Lists's "SelectedItem..."
  • How to abstract this? Classes don't overload or derive! That's NASTY
    • Insteads, implement a protocol!
    • Note: Protocol is the formal definition, delegate are the callback function prototypes

10 of 11

Protocol Example

Your UIViewController object needs to catch GPS update data. How?

  1. Register this instance with the GPS data
  2. Implement the protocol:

CoreLocationControllerDelegate

  • Recieve data, when ready, through delegate functions:

@protocol CoreLocationControllerDelegate �@required�- (void)locationUpdate:(CLLocation *)location;�- (void)locationError:(NSError *)error;

@end

11 of 11

Demo!

1. Formal protocol implementation

Example: Catch user events

2. Casual delegate implementation

Example: timers