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.

iOS View Coordinators

4,076 views

Published on

Slides from a talk about reducing the complexity in UIViewController classes for iOS using a pattern of smaller view coordinators

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

iOS View Coordinators

  1. 1. Avoiding oversized view controllers in iOS Stewart Gleadow Email: sgleadow@thoughtworks.com Twitter: @stewgleadow
  2. 2. What makes a classeasy to maintain?
  3. 3. UIViewUIViewController Model
  4. 4. What makes acontroller easy to maintain?
  5. 5. UIViewController- (id)init;- (void)loadView;- (void)viewDidLoad;- (void)viewWillAppear:(BOOL);- (void)viewDidAppear:(BOOL);- (void)viewWillDisappear:(BOOL);- (void)viewDidDisappear: (BOOL);- (void)viewDidUnload;- (void)dealloc;
  6. 6. UIViewController- (id)init;- (void)loadView;- (void)viewDidLoad;- (void)viewWillAppear:(BOOL);- (void)viewDidAppear:(BOOL);- (void)viewWillDisappear:(BOOL);- (void)viewDidDisappear: (BOOL);- (void)viewDidUnload;- (void)dealloc;
  7. 7. UIViewController- (id)init;- (void)loadView;- (void)viewDidLoad;- (void)viewWillAppear:(BOOL);- (void)viewDidAppear:(BOOL);- (void)viewWillDisappear:(BOOL);- (void)viewDidDisappear: (BOOL);- (void)viewDidUnload;- (void)dealloc;
  8. 8. - (id)init;{ if ((self = [super init])) { // create data related objects } return self;}- (void)dealloc;{ // release any data related objects [super dealloc];}
  9. 9. - (void)loadView;{ [super loadView]; // create all your views // assign delegates}- (void)viewDidUnload;{ // release any view related [super viewDidUnload];}
  10. 10. @interface MatchViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate, TTModelDelegate, ...>
  11. 11. Coordinated Views View One View Two View Three
  12. 12. Coordinator- (id)init;- (UIView *)view;- (void)releaseView;- (void)dealloc;
  13. 13. ViewController Coordinator- (id)init; - (id)init;- (void)loadView; - (UIView *)view;- (void)viewDidLoad; - (void)releaseView;- (void)viewWillAppear:(BOOL);- (void)viewDidAppear:(BOOL); - (void)dealloc;- (void)viewWillDisappear:(BOOL);- (void)viewDidDisappear: (BOOL);- (void)viewDidUnload;- (void)dealloc;
  14. 14. ViewController Coordinator- (id)init; - (id)init;- (void)loadView; - (UIView *)view;- (void)viewDidLoad; - (void)releaseView;- (void)viewWillAppear:(BOOL);- (void)viewDidAppear:(BOOL); - (void)dealloc;- (void)viewWillDisappear:(BOOL);- (void)viewDidDisappear: (BOOL);- (void)viewDidUnload;- (void)dealloc;
  15. 15. ViewController Coordinator- (id)init; - (id)init;- (void)loadView; - (UIView *)view;- (void)viewDidLoad; - (void)releaseView;- (void)viewWillAppear:(BOOL);- (void)viewDidAppear:(BOOL); - (void)dealloc;- (void)viewWillDisappear:(BOOL);- (void)viewDidDisappear: (BOOL);- (void)viewDidUnload;- (void)dealloc;
  16. 16. Demo
  17. 17. Stewart GleadowEmail:sgleadow@thoughtworks.comTwitter:@stewgleadow

×