First Steps in iOS Development

4,177 views

Published on

Have you always been interested in iOS development but never took the plunge and installed the dev tools? In this presentation we look at the basic steps of iOS application development, and then move on to slightly more advanced features like storyboards and segues (introduced with iOS 5).

Published in: Technology, Lifestyle
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,177
On SlideShare
0
From Embeds
0
Number of Embeds
31
Actions
Shares
0
Downloads
58
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

First Steps in iOS Development

  1. 1. First Steps in iOS Development Sasha Goldshtein CTO, Sela Group @goldshtn blog.sashag.net
  2. 2. Join the conversation on Twitter: @SoftArchConf #SoftArchConf The iOS Platform
  3. 3. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Platform Philosophy
  4. 4. Join the conversation on Twitter: @SoftArchConf #SoftArchConf iOS Devices and Versions September 2013: ≈95% of iOS devices run iOS 6
  5. 5. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Devices and Resolutions Don’t worry about Retina: all you need to do is provide 2x images for your graphical assets Don’t worry about iPhone 5: most views will resize correctly with AutoLayout or require minimal tweaks
  6. 6. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Developing for iOS self.title = [NSString initWithFormat:@"%d", n]; [button setTitle:self.title forState:UIControlStateNormal];
  7. 7. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Objective C Classes • Declare in .h file, implement in .m file – @interface and @implementation keywords
  8. 8. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Methods @interface Cat : NSObject - (void)meow; - (BOOL)doesLikeOtherCat:(Cat *)other; - (int)age; @end @implementation Cat - (void)meow { NSLog(@"Meow"); } - (int)age { return 7; } - (BOOL)doesLikeOtherCat:(Cat *)other { if ([self age] <= [other age]) return YES; return NO; } @end Q: What about nil checks?! A: Messages sent to nil return 0/nil/NO
  9. 9. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Initializers @interface Cat : Mammal { int age_; // This is a public instance field } - (id)initWithAge:(int)age; @end @implementation Cat - (id)initWithAge:(int)age { self = [super init]; if (self) age_ = age; return self; } @end
  10. 10. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Properties @interface Cat : NSObject @property (nonatomic) int age; - (id)initWithAge:(int)age; @end @implementation Cat - (id)initWithAge:(int)age { if (self = [super init]) _age = age; // Auto-generated field! return self; } @end
  11. 11. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Using Objects Cat *felix = [[Cat alloc] initWithAge:5]; Cat *shadow = [[Cat alloc] initWithAge:4]; if ([felix likesOtherCat:shadow]) { // Left to your imagination } NSDate *today = [NSDate date]; // Current date if ([Calendar isBirthday:shadow onDate:today]) { shadow.age++; [shadow meow]; }
  12. 12. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Memory Management: ARC • Heap objects are reference counted – Support release, retain, retainCount messages • Automatic Reference Counting (ARC) takes care of memory management – The compiler embeds the appropriate reference counting messages automatically – Introduced in iOS 4 with LLVM compiler – With one caveat: reference cycles
  13. 13. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Basic Foundation Classes • Strings – Immutable/mutable, @"foo" syntax • Arrays – May contain any object type (NSObject) – Immutable/mutable, @[a, b, c] syntax • Dictionaries – Keys are usually strings, but don’t have to be – Immutable/mutable, @{ a : b } syntax
  14. 14. Join the conversation on Twitter: @SoftArchConf #SoftArchConf DEMO Our first iOS app
  15. 15. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Project Components • Generated files: – Application delegate – Initial view controller – Main storyboard – Property list – File for localizable strings – Application icons • Xcode also adds basic frameworks to your app
  16. 16. Join the conversation on Twitter: @SoftArchConf #SoftArchConf iOS MVC Fundamentals
  17. 17. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Outlets and Actions • Xcode connects views and controllers – Controller manipulates views through outlets – Controller receives events through actions @interface MyViewController : UIViewController @property (nonatomic, weak) IBOutlet UITextField *petName; - (IBAction)getQuote; @end
  18. 18. Join the conversation on Twitter: @SoftArchConf #SoftArchConf DEMO Connecting UI to code
  19. 19. Join the conversation on Twitter: @SoftArchConf #SoftArchConf iOS Navigation Types • Tab bar controller • Navigation controller
  20. 20. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Storyboards • The storyboard describes your application’s view controllers and connects them with segues
  21. 21. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Types of Segues
  22. 22. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Passing Parameters • Usually the source view controller sets properties or calls methods on the destination view controller - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { MySecondVC *vc = segue.destinationViewController; vc.itemToDisplay = [self selectedItem]; vc.delegate = self; // For callbacks }
  23. 23. Join the conversation on Twitter: @SoftArchConf #SoftArchConf DEMO Storyboards and segues
  24. 24. Join the conversation on Twitter: @SoftArchConf #SoftArchConf Summary • It’s just another {language, IDE, UI framework} • The rest is just details: data, networking, settings, table views, styling, …
  25. 25. Thank You! Sasha Goldshtein CTO, Sela Group @goldshtn blog.sashag.net

×