Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Frederick web meetup slides

2,160 views

Published on

Published in: Technology
  • Be the first to comment

Frederick web meetup slides

  1. 1. iOS Development
  2. 2. iOS Development• About Me: • Pat Zearfoss • Mindgrub Technologies, LLC • BS Computer Science - UMBC 2008 • Working with mobile and iOS for 3 years.
  3. 3. iOS Development• Web: pzearfoss@gmail.com http://zearfoss.wordpress.com @pzearfoss http://www.github.com/pzearfoss
  4. 4. Development Options
  5. 5. Development OptionsHTML 5
  6. 6. Development OptionsHTML 5 Cross Platform
  7. 7. Development OptionsHTML 5 Cross Platform Native
  8. 8. HTML 5
  9. 9. HTML 5• Use the technologies you already know.
  10. 10. HTML 5• Use the technologies you already know.• Can be loaded into an app webview and distributed on the app store.
  11. 11. HTML 5• Use the technologies you already know.• Can be loaded into an app webview and distributed on the app store.• Limited use of device hardware.
  12. 12. HTML 5• Use the technologies you already know.• Can be loaded into an app webview and distributed on the app store.• Limited use of device hardware.• Cross Platform
  13. 13. HTML 5• Use the technologies you already know.• Can be loaded into an app webview and distributed on the app store.• Limited use of device hardware.• Cross Platform • Except for all the cross browser problems you already know and love.
  14. 14. Cross PlatformFrameworks
  15. 15. Cross Platform Frameworks• Titanium, PhoneGap, Others
  16. 16. Cross Platform Frameworks• Titanium, PhoneGap, Others• Use the technologies you already know.
  17. 17. Cross Platform Frameworks• Titanium, PhoneGap, Others• Use the technologies you already know.• Titanium generates native code.
  18. 18. Cross Platform Frameworks• Titanium, PhoneGap, Others• Use the technologies you already know.• Titanium generates native code.• PhoneGap uses web code in a webview.
  19. 19. Cross Platform Frameworks• Titanium, PhoneGap, Others• Use the technologies you already know.• Titanium generates native code.• PhoneGap uses web code in a webview.• Better use of device hardware.
  20. 20. Cross Platform Frameworks• Titanium, PhoneGap, Others• Use the technologies you already know.• Titanium generates native code.• PhoneGap uses web code in a webview.• Better use of device hardware.• “Cross Platform”
  21. 21. Cross Platform Frameworks• Titanium, PhoneGap, Others• Use the technologies you already know.• Titanium generates native code.• PhoneGap uses web code in a webview.• Better use of device hardware.• “Cross Platform” • Your mileage may vary.
  22. 22. Native
  23. 23. Native• Offers the most control over your product.
  24. 24. Native• Offers the most control over your product.• Access to all device frameworks.
  25. 25. Native• Offers the most control over your product.• Access to all device frameworks.• Requires Objective-C
  26. 26. Native• Offers the most control over your product.• Access to all device frameworks.• Requires Objective-C• Only runs on iOS (obviously)
  27. 27. Native• Offers the most control over your product.• Access to all device frameworks.• Requires Objective-C• Only runs on iOS (obviously)• Will generally run with the absolute best performance.
  28. 28. Xcode• Download from App Store $4.99 Download
  29. 29. Xcode• Download from App Store $4.99 Download
  30. 30. Xcode• Download from App Store $4.99 Download 4.1 is now free
  31. 31. Getting Started
  32. 32. Getting Started• Things you should know
  33. 33. Getting Started• Things you should know • Classical OO
  34. 34. Getting Started• Things you should know • Classical OO • Classes
  35. 35. Getting Started• Things you should know • Classical OO • Classes • Inheritance
  36. 36. Getting Started• Things you should know • Classical OO • Classes • Inheritance • Polymorphism
  37. 37. Getting Started
  38. 38. Getting Started• Recommended but not required
  39. 39. Getting Started• Recommended but not required • Some knowledge of C
  40. 40. Getting Started• Recommended but not required • Some knowledge of C • malloc() . . . free() ?
  41. 41. Getting Started• Recommended but not required • Some knowledge of C • malloc() . . . free() ? • Some knowledge of design patterns:
  42. 42. Getting Started• Recommended but not required • Some knowledge of C • malloc() . . . free() ? • Some knowledge of design patterns: • MVC, Singleton, Delegation
  43. 43. Objective-C in 10 minutes
  44. 44. About Objective-C
  45. 45. About Objective-C• Object Oriented superset over C
  46. 46. About Objective-C• Object Oriented superset over C Standard C
  47. 47. About Objective-C• Object Oriented superset over C Standard C Objective-C
  48. 48. About Objective-C• Object Oriented superset over C Standard C Objective-C• Anything that works in C will work in Objective-C
  49. 49. Obj-C in 10 minutes
  50. 50. Obj-C in 10 minutes• All the things you know from C
  51. 51. Obj-C in 10 minutes• All the things you know from C• Variables are typed:
  52. 52. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char
  53. 53. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char int foo = 5;
  54. 54. Obj-C in 10 minutes• All the things you know from C• Variables are typed: • int, float, double, char int foo = 5; • Separate compilation
  55. 55. 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
  56. 56. 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)
  57. 57. Obj-C in 10 minutes
  58. 58. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments
  59. 59. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments int sumOfItems(int i, int j) { return i + j; }
  60. 60. Obj-C in 10 minutes• Functions / Methods have return types and typed arguments int sumOfItems(int i, int j) { return i + j; }• Other types
  61. 61. 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
  62. 62. 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 *)
  63. 63. Obj-C in 10 minutes
  64. 64. Obj-C in 10 minutes• Objective-C Additions:
  65. 65. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO
  66. 66. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO BOOL isSet = YES;
  67. 67. Obj-C in 10 minutes• Objective-C Additions: • BOOL - YES / NO BOOL isSet = YES; • id - strictly a pointer to an object
  68. 68. 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
  69. 69. 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
  70. 70. Obj-C in 10 minutes
  71. 71. Obj-C in 10 minutes• Classes
  72. 72. Obj-C in 10 minutes• Classes • Exist as a class pair
  73. 73. Obj-C in 10 minutes• Classes • Exist as a class pair • Instance variables and instance methods act on an instance object
  74. 74. 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
  75. 75. 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
  76. 76. 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
  77. 77. 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
  78. 78. 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
  79. 79. 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
  80. 80. 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
  81. 81. Obj-C in 10 minutes• Classes #import <Foundation/Foundation.h> @interface MyClass : NSObject { id aChildObject; NSArray *someItems; } A class (static) + (NSString *)className; - (void)logMe; method @property (nonatomic, retain) id aChildObject; @end
  82. 82. 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
  83. 83. 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
  84. 84. 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
  85. 85. 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
  86. 86. 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; }
  87. 87. Obj-C in 10 minutes• Classes Include a header #import "MyClass.h" file @implementation MyClass @synthesize aChildObject; - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
  88. 88. 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; }
  89. 89. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass Auto-generate @synthesize aChildObject; property - (id)init { self = [super init]; if (self) { someItems = [[NSArray alloc] init]; } return self; }
  90. 90. 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; }
  91. 91. 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; }
  92. 92. Obj-C in 10 minutes• Classes #import "MyClass.h" @implementation MyClass @synthesize aChildObject; - (id)init { Call to super self = [super init]; if (self) class { someItems = [[NSArray alloc] init]; } return self; }
  93. 93. 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; }
  94. 94. 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; }
  95. 95. 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
  96. 96. 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
  97. 97. 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
  98. 98. 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
  99. 99. 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
  100. 100. 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
  101. 101. Obj-C in 10 minutes
  102. 102. Obj-C in 10 minutes• What’s with all the ‘@’ and ‘[ ]’?
  103. 103. Obj-C in 10 minutes• What’s with all the ‘@’ and ‘[ ]’?•@ • Objective-C keywords • Initializer for string constants
  104. 104. 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
  105. 105. Obj-C in 10 minutes
  106. 106. Obj-C in 10 minutes• Method Calls (messages)
  107. 107. Obj-C in 10 minutes• Method Calls (messages)• Names are intermixed with arguments:
  108. 108. Obj-C in 10 minutes• Method Calls (messages)• Names are intermixed with arguments: • method definition - (void)setItems:(NSArray *)items childObject:(id)obj;
  109. 109. 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];
  110. 110. Obj-C in 10 minutes- (void)setItems:(NSArray *)items childObject:(id)obj;
  111. 111. Obj-C in 10 minutes Return Type- (void)setItems:(NSArray *)items childObject:(id)obj;
  112. 112. Obj-C in 10 minutes Return Type- (void)setItems:(NSArray *)items childObject:(id)obj; Method Name
  113. 113. Obj-C in 10 minutes Return Type Arguments and Types- (void)setItems:(NSArray *)items childObject:(id)obj; Method Name
  114. 114. Obj-C in 10 minutes[self setItems:[NSArray array] childObject:object];
  115. 115. Obj-C in 10 minutesReceiver [self setItems:[NSArray array] childObject:object];
  116. 116. Obj-C in 10 minutesReceiver [self setItems:[NSArray array] childObject:object]; Method Name
  117. 117. Obj-C in 10 minutesReceiver Arguments [self setItems:[NSArray array] childObject:object]; Method Name
  118. 118. Obj-C in 10 minutes
  119. 119. Obj-C in 10 minutes• Protocols
  120. 120. Obj-C in 10 minutes• Protocols • Analogous to interfaces @protocol MyProtocol <NSObject> - (void)protocolMethod; @property (nonatomic, retain) NSObject *anObject; @end
  121. 121. 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>
  122. 122. 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
  123. 123. Xcode Tour• Located in /Developer/Applications
  124. 124. Code Editor
  125. 125. Navigator
  126. 126. Utilities
  127. 127. Debug Area
  128. 128. Run Controls
  129. 129. Status Window (???)
  130. 130. Window Configuration
  131. 131. Run Controls Status Window (???) Window ConfigurationNavigator Code Editor Utilities Debug Area
  132. 132. Hello World
  133. 133. Model-View-Controller
  134. 134. Model-View-ControllerModel
  135. 135. Model-View-ControllerModel View
  136. 136. Model-View-ControllerModel Controller View
  137. 137. Model • Defines the data to be displayed in a view. • Model objects • DatabaseModel • Web
  138. 138. Controller • Negotiates communication between the model and the view. • Controls presentation logic • Updates the modelController • Reflects those updates on the view
  139. 139. View • Contains controls and UI Widgets • Informs the controller of updates.View
  140. 140. Hello WorldModel Controller View (Hello_WorldViewController) (.xib) Label view
  141. 141. Hello WorldModel Controller View (Hello_WorldViewController) (.xib) Label view
  142. 142. Hello WorldModel Controller View (Hello_WorldViewController) (.xib) Label view
  143. 143. Hello You
  144. 144. Hello You• Basic string handling• Button control• TextField control• Outlets and Actions• Basic MVC
  145. 145. Hello You Model Controller View (HelloYouViewController) (.xib)NSString: name view textField textField label label buttonTap: button
  146. 146. Locations
  147. 147. Locations• CoreLocation• UITableview• Delegate Pattern
  148. 148. HTML Photo
  149. 149. HTML App• Shows interaction between webview content and the native development kit.• Modal View Controllers• UIImagePickerController
  150. 150. The HTML<html> <head> <meta name = "viewport" content = "width = device-width"> </head> <body> <h1>Tap for photo</h1> <input type="button" value="Get Photo" onClick="window.location=http://getphoto"/> <img width="320" height="200" id="image"/> </body></html>
  151. 151. The JavaScriptvar image=document.getElementById(image);image.src = %@ • %@ will be replaced by the image url
  152. 152. Loading the webviewNSError *error;NSString *filename = [[NSBundle mainBundle] pathForResource:@"webview" ofType:@"html"];NSString *html = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];[webview loadHTMLString:html baseURL:nil];
  153. 153. Intercepting the URL- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ if ([[[request URL] absoluteString] isEqualToString:@"http://getphoto/"]) { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.modalPresentationStyle = UIModalTransitionStyleCoverVertical; picker.delegate = self; [self presentModalViewController:picker animated:YES]; return NO; } return YES;}
  154. 154. iOS Development• Web: pzearfoss@gmail.com http://zearfoss.wordpress.com @pzearfoss http://www.github.com/pzearfoss

×