Fwt ios 5

1,225 views

Published on

My slides for the FWT meetup on 4/11/12

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
1,225
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Fwt ios 5

    1. 1. iOS 5
    2. 2. iOS 5• About Me: • Pat Zearfoss • Mindgrub Technologies, LLC • BS Computer Science - UMBC 2008 • Working with mobile and iOS for 4 years.
    3. 3. iOS 5• Web: pzearfoss@gmail.com http://zearfoss.wordpress.com @pzearfoss http://www.github.com/pzearfoss
    4. 4. Where we’re going:
    5. 5. Where we’re going:• Quick Objective-c and iOS review
    6. 6. Where we’re going:• Quick Objective-c and iOS review• Overview of iOS 5 additions and changes
    7. 7. Where we’re going:• Quick Objective-c and iOS review• Overview of iOS 5 additions and changes• Introducing Lobstagram
    8. 8. Where we’re going:• Quick Objective-c and iOS review• Overview of iOS 5 additions and changes• Introducing Lobstagram• Other iOS 5 features (as time permits)
    9. 9. About iOS Development
    10. 10. About iOS Development• Objective-c only
    11. 11. About iOS Development• Objective-c only • Other tools are getting better:
    12. 12. About iOS Development• Objective-c only • Other tools are getting better: • Titanium, PhoneGap, MonoTouch
    13. 13. About iOS Development• Objective-c only • Other tools are getting better: • Titanium, PhoneGap, MonoTouch• Mac required
    14. 14. About iOS Development• Objective-c only • Other tools are getting better: • Titanium, PhoneGap, MonoTouch• Mac required• Xcode required (free!)
    15. 15. Xcode• Download from App Store
    16. 16. Objective-c crash course
    17. 17. Getting Started
    18. 18. Getting Started• Things you should know
    19. 19. Getting Started• Things you should know • Classical OO
    20. 20. Getting Started• Things you should know • Classical OO • Classes
    21. 21. Getting Started• Things you should know • Classical OO • Classes • Inheritance
    22. 22. Getting Started• Things you should know • Classical OO • Classes • Inheritance • Polymorphism
    23. 23. Getting Started
    24. 24. Getting Started• Recommended but not required
    25. 25. Getting Started• Recommended but not required • Some knowledge of C
    26. 26. Getting Started• Recommended but not required • Some knowledge of C • malloc() . . . free() ?
    27. 27. Getting Started• Recommended but not required • Some knowledge of C • malloc() . . . free() ? • Some knowledge of design patterns:
    28. 28. Getting Started• Recommended but not required • Some knowledge of C • malloc() . . . free() ? • Some knowledge of design patterns: • MVC, Singleton, Delegation
    29. 29. About Objective-C
    30. 30. About Objective-C• Object Oriented superset over C
    31. 31. About Objective-C• Object Oriented superset over C Standard C
    32. 32. About Objective-C• Object Oriented superset over C Standard C Objective-C
    33. 33. About Objective-C• Object Oriented superset over C Standard C Objective-C• Anything that works in C will work in Objective-C
    34. 34. Obj-C in 10 minutes
    35. 35. Obj-C in 10 minutes• All the things you know from C
    36. 36. Obj-C in 10 minutes• All the things you know from C• Variables are typed:
    37. 37. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char
    38. 38. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char int foo = 5;
    39. 39. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char int foo = 5; • Separate compilation
    40. 40. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char int foo = 5; • Separate compilation • .h for interface declaration
    41. 41. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char int foo = 5; • Separate compilation • .h for interface declaration • .m for implementation (instead of .c)
    42. 42. Obj-C in 10 minutes
    43. 43. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments
    44. 44. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments int sumOfItems(int i, int j) { return i + j; }
    45. 45. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments int sumOfItems(int i, int j) { return i + j; }• Other types
    46. 46. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments int sumOfItems(int i, int j) { return i + j; }• Other types • void, NULL
    47. 47. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments int sumOfItems(int i, int j) { return i + j; }• Other types • void, NULL • pointers to types (int *, void *)
    48. 48. Obj-C in 10 minutes
    49. 49. Obj-C in 10 minutes• Objective-C Additions:
    50. 50. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO
    51. 51. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO BOOL isSet = YES;
    52. 52. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO BOOL isSet = YES; • id - strictly a pointer to an object
    53. 53. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO BOOL isSet = YES; • id - strictly a pointer to an object • nil - a zero’d out pointer
    54. 54. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO BOOL isSet = YES; • id - strictly a pointer to an object • nil - a zero’d out pointer • nil != (necessarily) NULL or 0
    55. 55. Obj-C in 10 minutes
    56. 56. Obj-C in 10 minutes• Classes
    57. 57. Obj-C in 10 minutes• Classes • Exist as a class pair
    58. 58. Obj-C in 10 minutes• Classes • Exist as a class pair • Instance variables and instance methods act on an instance object
    59. 59. Obj-C in 10 minutes• Classes • Exist as a class pair • Instance variables and instance methods act on an instance object • Class (static) methods act on the class object
    60. 60. Obj-C in 10 minutes• Classes • Exist as a class pair • Instance variables and instance methods act on an instance object • Class (static) methods act on the class object • There is only ever one class object at any given time
    61. 61. Obj-C in 10 minutes• Classes • Exist as a class pair • Instance variables and instance methods act on an instance object • Class (static) methods act on the class object • There is only ever one class object at any given time • Class variables really don’t exist
    62. 62. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } + (NSString *)className; - (void)logMe; @property (nonatomic, retain) id aChildObject; @end
    63. 63. Obj-C in 10 minutes• Classes Include a header #import <Foundation/Foundation.h> file @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } + (NSString *)className; - (void)logMe; @property (nonatomic, retain) id aChildObject; @end
    64. 64. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> Declare interface @interface MyClass : NSObject extends { NSObject id aChildObject; NSArray *someItems; } + (NSString *)className; - (void)logMe; @property (nonatomic, retain) id aChildObject; @end
    65. 65. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; Class instance NSArray *someItems; variables } + (NSString *)className; - (void)logMe; @property (nonatomic, retain) id aChildObject; @end
    66. 66. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } + (NSString *)className; A class (static) - (void)logMe; method @property (nonatomic, retain) id aChildObject; @end
    67. 67. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } + (NSString *)className; - (void)logMe; An instance method @property (nonatomic, retain) id aChildObject; @end
    68. 68. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } A declared + (NSString *)className; property - (void)logMe; @property (nonatomic, retain) id aChildObject; @end
    69. 69. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } + (NSString *)className; - (void)logMe; @property (nonatomic, retain) id aChildObject; Close the @end interface block
    70. 70. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } + (NSString *)className; - (void)logMe; @property (nonatomic, retain) id aChildObject; @end
    71. 71. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    72. 72. Obj-C in 10 minutes• Classes #import "MyClass.h" Include a header file @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    73. 73. Obj-C in 10 minutes• Classes #import "MyClass.h" Begin @implementation MyClass implementation @synthesize aChildObject; block - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    74. 74. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; Auto-generate property - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    75. 75. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init Initializer { (constructor) self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    76. 76. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    77. 77. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; Call to super if (self) class { someItems = [[NSArray alloc] init]; } return self; }
    78. 78. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; “new” an array if (self) { someItems = [[NSArray alloc] init]; } return self; }
    79. 79. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    80. 80. Obj-C in 10 minutes• Continued . . . - (void)dealloc { [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe { NSLog(@"MyClass"); } + (NSString *)className { return NSStringFromClass([self class]); } @end
    81. 81. Obj-C in 10 minutes• Continued . . . - (void)dealloc { Destructor [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe { NSLog(@"MyClass"); } + (NSString *)className { return NSStringFromClass([self class]); } @end
    82. 82. Obj-C in 10 minutes• Continued . . . - (void)dealloc { [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe Instance method { implementation NSLog(@"MyClass"); } + (NSString *)className { return NSStringFromClass([self class]); } @end
    83. 83. Obj-C in 10 minutes• Continued . . . - (void)dealloc { [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe { NSLog(@"MyClass"); Class method } implementation + (NSString *)className { return NSStringFromClass([self class]); } @end
    84. 84. Obj-C in 10 minutes• Continued . . . - (void)dealloc { [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe { NSLog(@"MyClass"); } + (NSString *)className { return NSStringFromClass([self class]); End } implementation @end block
    85. 85. Obj-C in 10 minutes• Continued . . . - (void)dealloc { [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe { NSLog(@"MyClass"); } + (NSString *)className { return NSStringFromClass([self class]); } @end
    86. 86. Obj-C in 10 minutes
    87. 87. Obj-C in 10 minutes• What’s with all the ‘@’ and ‘[ ]’?
    88. 88. Obj-C in 10 minutes• What’s with all the ‘@’ and ‘[ ]’?•@ • Objective-C keywords • Initializer for string constants
    89. 89. Obj-C in 10 minutes• What’s with all the ‘@’ and ‘[ ]’?•@ • Objective-C keywords • Initializer for string constants• ‘[]’ • “Send a message to an object” • Like calling a method, but more dynamic
    90. 90. Obj-C in 10 minutes
    91. 91. Obj-C in 10 minutes• Method Calls (messages)
    92. 92. Obj-C in 10 minutes• Method Calls (messages)• Names are intermixed with arguments:
    93. 93. Obj-C in 10 minutes• Method Calls (messages)• Names are intermixed with arguments: • method definition - (void)setItems:(NSArray *)items childObject:(id)obj;
    94. 94. Obj-C in 10 minutes• Method Calls (messages)• Names are intermixed with arguments: • method definition - (void)setItems:(NSArray *)items childObject:(id)obj; • method call [self setItems:[NSArray array] childObject:object];
    95. 95. Obj-C in 10 minutes- (void)setItems:(NSArray *)items childObject:(id)obj;
    96. 96. Obj-C in 10 minutesReturn Type- (void)setItems:(NSArray *)items childObject:(id)obj;
    97. 97. Obj-C in 10 minutesReturn Type- (void)setItems:(NSArray *)items childObject:(id)obj; Method Name
    98. 98. Obj-C in 10 minutesReturn Type Arguments and Types- (void)setItems:(NSArray *)items childObject:(id)obj; Method Name
    99. 99. Obj-C in 10 minutes[self setItems:[NSArray array] childObject:object];
    100. 100. Obj-C in 10 minutesReceiver [self setItems:[NSArray array] childObject:object];
    101. 101. Obj-C in 10 minutesReceiver [self setItems:[NSArray array] childObject:object]; Method Name
    102. 102. Obj-C in 10 minutesReceiver Arguments [self setItems:[NSArray array] childObject:object]; Method Name
    103. 103. Obj-C in 10 minutes
    104. 104. Obj-C in 10 minutes• Protocols
    105. 105. Obj-C in 10 minutes• Protocols • Analogous to interfaces @protocol MyProtocol <NSObject> - (void)protocolMethod; @property (nonatomic, retain) NSObject *anObject; @end
    106. 106. Obj-C in 10 minutes• Protocols • Analogous to interfaces @protocol MyProtocol <NSObject> - (void)protocolMethod; @property (nonatomic, retain) NSObject *anObject; @end • Adopting a protocol @interface MyClass : NSObject <MyProtocol>
    107. 107. Obj-C in 10 minutes• Categories - Something completely different• Add functionality to an existing class @interface NSString (firstChar) - (unichar)firstChar; @end @implementation NSString (reverse) - (unichar)firstChar { return [self characterAtIndex:0]; } @end
    108. 108. iOS in 10 Minutes
    109. 109. Key Objects
    110. 110. Key Objects• UIViewController • Contains a view, manages all the information and widgets on the view. • One Controller per view (screen)
    111. 111. Key Objects• UIViewController • Contains a view, manages all the information and widgets on the view. • One Controller per view (screen)• UIView • The view itself. All UI widgets inherit from UIView. • Objects on a view are “subviews” of that view
    112. 112. Key PatternsMVC
    113. 113. Key Patterns MVCModel
    114. 114. Key Patterns MVCModel View
    115. 115. Key Patterns MVCModel Controller View
    116. 116. Key Patterns
    117. 117. Key Patterns• Delegation (Datasource)
    118. 118. Key Patterns• Delegation (Datasource) • Alleviates subclassing
    119. 119. Key Patterns • Delegation (Datasource) • Alleviates subclassing“I’m a table view. The user tapped the fourth cell.Thought you should know.”
    120. 120. Key Patterns • Delegation (Datasource) • Alleviates subclassing“I’m a table view. You need to give me a cell object todisplay at row 5. I don’t really care what’s in it.”
    121. 121. Delegation Delegate
    122. 122. Delegation Delegate“How many sections?”
    123. 123. Delegation Delegate“How many sections?” “1”
    124. 124. Delegation Delegate“How many sections?” “1”“How many rows?”
    125. 125. Delegation Delegate“How many sections?” “1”“How many rows?” “2”
    126. 126. Delegation Delegate
    127. 127. Delegation Delegate“I need a cell for row 0”
    128. 128. Delegation Delegate“I need a cell for row 0”
    129. 129. Delegation Delegate“I need a cell for row 0”“Someone tapped row 0”
    130. 130. UITableView• Interface declares the datasource and delegate protocols:
    131. 131. UITableView• Interface declares the datasource and delegate protocols: @interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
    132. 132. UITableview• Implements the required methods:
    133. 133. UITableview• Implements the required methods: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
    134. 134. iOS 5
    135. 135. iOS 5• Thousands of new APIs• Newly available frameworks• Game Center• Automatic Reference Counting• Storyboards• iCloud• It’s really really really big
    136. 136. Things we’ll cover:
    137. 137. Things we’ll cover:• Automatic Reference Counting
    138. 138. Things we’ll cover:• Automatic Reference Counting• Twitter framework
    139. 139. Things we’ll cover:• Automatic Reference Counting• Twitter framework• UIAppearance customization
    140. 140. Things we’ll cover:• Automatic Reference Counting• Twitter framework• UIAppearance customization• CoreImage Filters
    141. 141. Lobstagram
    142. 142. A Brief Tour
    143. 143. A Brief Tour• A Table View of images already taken
    144. 144. A Brief Tour• A Table View of images already taken• Camera button chooses a photo (or takes a photo)
    145. 145. A Brief Tour• A Table View of images already taken• Camera button chooses a photo (or takes a photo)• Next view applies the photo title and saves to CoreData
    146. 146. A Brief Tour• A Table View of images already taken• Camera button chooses a photo (or takes a photo)• Next view applies the photo title and saves to CoreData• Table refreshes.
    147. 147. A Brief Tour• A Table View of images already taken• Camera button chooses a photo (or takes a photo)• Next view applies the photo title and saves to CoreData• Table refreshes.• Not worth $1 Billion
    148. 148. A Brief Tour
    149. 149. A Brief Tour• UITableView as described earlier.
    150. 150. A Brief Tour• UITableView as described earlier.• UIImagePickerViewController is an easy to use built in control.
    151. 151. A Brief Tour• UITableView as described earlier.• UIImagePickerViewController is an easy to use built in control.• CoreData is an ORM on steroids for working with persistent storage.
    152. 152. A Brief Tour• UITableView as described earlier.• UIImagePickerViewController is an easy to use built in control.• CoreData is an ORM on steroids for working with persistent storage.• All written in ARC code.
    153. 153. The Dark Ages
    154. 154. The Dark Ages• Manual Memory Management
    155. 155. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python
    156. 156. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python • Reference counting system implemented on NSObject.
    157. 157. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python • Reference counting system implemented on NSObject. • alloc . . . init
    158. 158. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python • Reference counting system implemented on NSObject. • alloc . . . init • retain
    159. 159. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python • Reference counting system implemented on NSObject. • alloc . . . init • retain • release
    160. 160. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python • Reference counting system implemented on NSObject. • alloc . . . init • retain • release • autorelease
    161. 161. The Dark Ages• Manual Memory Management • No garbage collection as in C#, Java, Ruby, PHP, Python • Reference counting system implemented on NSObject. • alloc . . . init • retain • release • autorelease • dealloc
    162. 162. Manual Memory Management• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
    163. 163. Manual Memory Management• Continued . . . - (void)dealloc { [aChildObject release]; [someItems release]; [super dealloc]; } - (void)logMe { NSLog(@"MyClass"); } + (NSString *)className { return NSStringFromClass([self class]); } @end
    164. 164. No Longer
    165. 165. To The Code!
    166. 166. ARC Decorators
    167. 167. ARC Decorators• __strong - owning reference (default)
    168. 168. ARC Decorators• __strong - owning reference (default)• __weak - non-owning reference
    169. 169. ARC Decorators• __strong - owning reference (default)• __weak - non-owning reference• __unsafe_unretained - manual management
    170. 170. ARC Decorators• __strong - owning reference (default)• __weak - non-owning reference• __unsafe_unretained - manual management• __autoreleasing - used in out parameters
    171. 171. ARC Decorators• __strong - owning reference (default)• __weak - non-owning reference• __unsafe_unretained - manual management• __autoreleasing - used in out parameters• No dealloc
    172. 172. Using __weak• Use __weak to refer to an object that you’re confident will be retained elsewhere.
    173. 173. Using __weak• Use __weak to refer to an object that you’re confident will be retained elsewhere. NSArray *array = [NSArray arrayWithObjects:@"foo", @"bar", @"baz", nil]; // The array is owning all the objects in it, so we dont // need a strong reference here (but theres nothing wrong with it) NSString * __weak first = [array objectAtIndex:0];
    174. 174. __unsafe_unretained
    175. 175. __unsafe_unretained• Used for backwards compatibility with iOS 4.
    176. 176. __unsafe_unretained• Used for backwards compatibility with iOS 4.• Pointer is NOT nil’d out after deallocation.
    177. 177. __unsafe_unretained• Used for backwards compatibility with iOS 4.• Pointer is NOT nil’d out after deallocation. // nil initialization is automatic NSNumber * __unsafe_unretained n = nil; if (YES) { n = [[NSNumber alloc] initWithInt:25]; NSLog(@"%@", n); } // n loses scope NSLog(@"%@", n); // CRASH! (probably)
    178. 178. __unsafe_unretained• Used for backwards compatibility with iOS 4.• Pointer is NOT nil’d out after deallocation. // nil initialization is automatic NSNumber * __unsafe_unretained n = nil; if (YES) { n = [[NSNumber alloc] initWithInt:25]; NSLog(@"%@", n); } // n loses scope n = nil; NSLog(@"%@", n); // a-ok
    179. 179. __autoreleasing • Used with out parametersNSError * __autoreleasing error = nil;if (![managedObjectContext save:&error]){ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The photo could not be saved" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show];}else{ [delegate photoSettingsViewController:self didSaveNewPhoto:photo];} • (Note, the compiler will rewrite this if you use a strong reference)
    180. 180. So what?
    181. 181. So what?• ARC drastically reduces up front development time.
    182. 182. So what?• ARC drastically reduces up front development time.• ARC drastically reduces debugging time.
    183. 183. So what?• ARC drastically reduces up front development time.• ARC drastically reduces debugging time.• ARC is not perfect:
    184. 184. So what?• ARC drastically reduces up front development time.• ARC drastically reduces debugging time.• ARC is not perfect: • Still possible to have retain cycle
    185. 185. So what?• ARC drastically reduces up front development time.• ARC drastically reduces debugging time.• ARC is not perfect: • Still possible to have retain cycle • Still need to understand pointer scope
    186. 186. So what?• ARC drastically reduces up front development time.• ARC drastically reduces debugging time.• ARC is not perfect: • Still possible to have retain cycle • Still need to understand pointer scope • Doesn’t work on CF objects
    187. 187. So what?• ARC drastically reduces up front development time.• ARC drastically reduces debugging time.• ARC is not perfect: • Still possible to have retain cycle • Still need to understand pointer scope • Doesn’t work on CF objects• The compiler is smarter than you.
    188. 188. Twitter Integration (Couldn’t be easier)
    189. 189. Twitter.framework
    190. 190. Twitter.framework• TWTweetComposeViewController
    191. 191. Twitter.framework• TWTweetComposeViewController • Super easy view for composing a tweet
    192. 192. Twitter.framework• TWTweetComposeViewController • Super easy view for composing a tweet• TWRequest
    193. 193. Twitter.framework• TWTweetComposeViewController • Super easy view for composing a tweet• TWRequest • Encapsulates the handling of HTTP requests to the Twitter server.
    194. 194. Twitter.framework• TWTweetComposeViewController • Super easy view for composing a tweet• TWRequest • Encapsulates the handling of HTTP requests to the Twitter server.• Requires the user to have set up Twitter in the device’s settings.
    195. 195. Tweet Composer• Appears looking great automatically.• Can add links and images• Literally zero configuration.
    196. 196. To The Code!
    197. 197. CustomizingAppearance
    198. 198. Not a billion dollar app
    199. 199. The Dark Ages
    200. 200. The Dark Ages• UI Customization was labor intensive
    201. 201. The Dark Ages• UI Customization was labor intensive• Every instance of a widget had to be customized individually.
    202. 202. The Dark Ages• UI Customization was labor intensive• Every instance of a widget had to be customized individually. • Subclassing
    203. 203. The Dark Ages• UI Customization was labor intensive• Every instance of a widget had to be customized individually. • Subclassing • Helper methods
    204. 204. The Dark Ages• UI Customization was labor intensive• Every instance of a widget had to be customized individually. • Subclassing • Helper methods • Overriding drawRect or haphazardly adding subviews.
    205. 205. UIAppearance• Certain UI Widgets expose an “appearance proxy” which can be customized once and the look persists everywhere. [[UINavigationBar appearance] setTitleTextAttributes:navBarTextProperties]; [[UILabel appearanceWhenContainedIn:[UIButton class], nil] setTextColor: [UIColor whiteColor]];• Elements can also be customized individually via the same methods.
    206. 206. What it’s not . . .• A Cascading Style Sheet • Outermost rule breaks a tie- breaker • No way to specify things by Id • Unexpected consequences . . .
    207. 207. To The Code!
    208. 208. Much Better
    209. 209. Much Better
    210. 210. CoreImage
    211. 211. CoreImage
    212. 212. CoreImage• A mature Mac-OS framework brought to iOS.
    213. 213. CoreImage• A mature Mac-OS framework brought to iOS.• Built in inclusion of filters for use
    214. 214. CoreImage• A mature Mac-OS framework brought to iOS.• Built in inclusion of filters for use• Plays nice with UIImage and CGImageRef
    215. 215. CoreImage Bits
    216. 216. CoreImage Bits• CIImage - a recipe for creating an image.
    217. 217. CoreImage Bits• CIImage - a recipe for creating an image.• CIFilter - an ingredient in the recipe.
    218. 218. CoreImage Bits• CIImage - a recipe for creating an image.• CIFilter - an ingredient in the recipe.• CIContext - the mixing bowl
    219. 219. CoreImage Workflow
    220. 220. CoreImage Workflow• Create a CIContext
    221. 221. CoreImage Workflow• Create a CIContext• Grab an input image
    222. 222. CoreImage Workflow• Create a CIContext• Grab an input image• Declare and configure a filter
    223. 223. CoreImage Workflow• Create a CIContext• Grab an input image• Declare and configure a filter• Get the output image from the filter
    224. 224. CoreImage Workflow• Create a CIContext• Grab an input image• Declare and configure a filter• Get the output image from the filter• Billion dollar profit
    225. 225. Some caveats• Documentation is scant • The core image filter list applies to MacOS only. • To get the full list available on the iPhone:NSLog(@"%@", [CIFilter filterNamesInCategory:kCICategoryBuiltIn]); • There are filters in the device that aren’t documented.
    226. 226. To The Code!
    227. 227. iOS 5 Development• Web: pzearfoss@gmail.com http://zearfoss.wordpress.com @pzearfoss http://www.github.com/pzearfoss
    228. 228. https://github.com/pzearfoss/Lobstagram

    ×