Successfully reported this slideshow.

iOS View Coordinators

0

Share

Upcoming SlideShare
Beginning iPhone Development
Beginning iPhone Development
Loading in …3
×
1 of 25
1 of 25

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

iOS View Coordinators

  1. 1. Avoiding oversized view controllers in iOS Stewart Gleadow Email: sgleadow@thoughtworks.com Twitter: @stewgleadow
  2. 2. What makes a class easy to maintain?
  3. 3. UIView UIViewController Model
  4. 4. What makes a controller 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 Gleadow Email: sgleadow@thoughtworks.com Twitter: @stewgleadow

Editor's Notes

  • \n
  • \n
  • \n
  • - small classes\n- small methods\n- single responsibility\n- not much logic, just decoupling\n
  • - nav controller push/pop\n- low memory conditions (recycle the views)\n\n
  • - nav controller push/pop\n- low memory conditions (recycle the views)\n\n
  • \n
  • \n
  • \n
  • \n
  • - one UIViewController to rule them all (single responsibility?)\n- sub UIViewControllers: complicated lifecycle\n- custom UIView subclasses shouldn&amp;#x2019;t have delegate callbacks\n
  • - automatic layout in full width horizontal\n- independent sections of the screen\n
  • - simplified view controller\n- managed the creation of the view (holds it)\n- hides callbacks (can&amp;#x2019;t use UIView for that)\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • \n
  • \n
  • ×