SlideShare a Scribd company logo
Avoiding oversized
 view controllers
      in iOS

 Stewart Gleadow
 Email:
 sgleadow@thoughtworks.com

 Twitter:
 @stewgleadow
iOS View Coordinators
What makes a class
easy to maintain?
UIView


UIViewController


                   Model
iOS View Coordinators
What makes a
controller easy to
    maintain?
iOS View Coordinators
iOS View Coordinators
UIViewController

- (id)init;

-   (void)loadView;
-   (void)viewDidLoad;
-   (void)viewWillAppear:(BOOL);
-   (void)viewDidAppear:(BOOL);

- (void)viewWillDisappear:(BOOL);
- (void)viewDidDisappear: (BOOL);
- (void)viewDidUnload;

- (void)dealloc;
UIViewController

- (id)init;

-   (void)loadView;
-   (void)viewDidLoad;
-   (void)viewWillAppear:(BOOL);
-   (void)viewDidAppear:(BOOL);

- (void)viewWillDisappear:(BOOL);
- (void)viewDidDisappear: (BOOL);
- (void)viewDidUnload;

- (void)dealloc;
UIViewController

- (id)init;

-   (void)loadView;
-   (void)viewDidLoad;
-   (void)viewWillAppear:(BOOL);
-   (void)viewDidAppear:(BOOL);

- (void)viewWillDisappear:(BOOL);
- (void)viewDidDisappear: (BOOL);
- (void)viewDidUnload;

- (void)dealloc;
iOS View Coordinators
- (id)init;
{
  if ((self = [super init]))
  {
    // create data related objects
  }

    return self;
}

- (void)dealloc;
{
  // release any data related objects

    [super dealloc];
}
iOS View Coordinators
- (void)loadView;
{
  [super loadView];

    // create all your views

    // assign delegates
}

- (void)viewDidUnload;
{
  // release any view related

    [super viewDidUnload];
}
iOS View Coordinators
@interface MatchViewController : UIViewController

  <UITableViewDelegate,
  UITableViewDataSource,
  UIScrollViewDelegate,
  TTModelDelegate,
  ...>
Coordinated Views

       View One



       View Two




       View Three
Coordinator

- (id)init;

- (UIView *)view;
- (void)releaseView;

- (void)dealloc;
iOS View Coordinators
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;
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;
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;
Demo
Stewart Gleadow
Email:
sgleadow@thoughtworks.com

Twitter:
@stewgleadow

More Related Content

PPTX
Y hack-china-2013
PPT
Ionic tabs template explained
KEY
Beginning iPhone Development
KEY
Cocoa Design Patterns
PDF
Turbolinks 5 + PWA (Progressive Web Apps)
KEY
Agile iOS
PDF
Rambler.iOS #3: Dependency Injection в iOS
PDF
Rambler.iOS #4: Создание модульных приложений на примере Рамблер.Кассы
Y hack-china-2013
Ionic tabs template explained
Beginning iPhone Development
Cocoa Design Patterns
Turbolinks 5 + PWA (Progressive Web Apps)
Agile iOS
Rambler.iOS #3: Dependency Injection в iOS
Rambler.iOS #4: Создание модульных приложений на примере Рамблер.Кассы

Similar to iOS View Coordinators (20)

PDF
December 2014 University iOS Meetup Talk
PDF
Intro to UIKit • Made by Many
PDF
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
PDF
Creating Container View Controllers
PDF
201104 iphone navigation-based apps
PDF
UIViewControllerのコーナーケース
PDF
아이폰강의(5) pdf
PDF
Apple Templates Considered Harmful
PPTX
iOS Development (Part 2)
PDF
Leaving Interface Builder Behind
PDF
03 objective-c session 3
PPTX
Android and IOS UI Development (Android 5.0 and iOS 9.0)
PPTX
04 objective-c session 4
PDF
Introduction of Xcode
PDF
02 objective-c session 2
PDF
iOS (7) Workshop
PDF
20180721 code defragment
PDF
Programming iOS 14 11th Edition Matt Neuburg
PDF
Utilising View Controllers
PDF
아이폰강의(4) pdf
December 2014 University iOS Meetup Talk
Intro to UIKit • Made by Many
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
Creating Container View Controllers
201104 iphone navigation-based apps
UIViewControllerのコーナーケース
아이폰강의(5) pdf
Apple Templates Considered Harmful
iOS Development (Part 2)
Leaving Interface Builder Behind
03 objective-c session 3
Android and IOS UI Development (Android 5.0 and iOS 9.0)
04 objective-c session 4
Introduction of Xcode
02 objective-c session 2
iOS (7) Workshop
20180721 code defragment
Programming iOS 14 11th Edition Matt Neuburg
Utilising View Controllers
아이폰강의(4) pdf
Ad

More from sgleadow (11)

PDF
Evolving Mobile Architectures @ Mi9
PDF
Evolving for Multiple Screens
PDF
Mobile: more than just an app
PDF
Evolving Mobile Architectures
PPT
Building mobile teams and getting a product to market
KEY
iOS Unit Testing
PDF
iOS app case study
KEY
Frank iOS Testing
PDF
Multithreaded Data Transport
PPTX
A few design patterns
PPT
GPU Programming
Evolving Mobile Architectures @ Mi9
Evolving for Multiple Screens
Mobile: more than just an app
Evolving Mobile Architectures
Building mobile teams and getting a product to market
iOS Unit Testing
iOS app case study
Frank iOS Testing
Multithreaded Data Transport
A few design patterns
GPU Programming
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Tartificialntelligence_presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Programs and apps: productivity, graphics, security and other tools
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
Tartificialntelligence_presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation

iOS View Coordinators

  • 1. Avoiding oversized view controllers in iOS Stewart Gleadow Email: sgleadow@thoughtworks.com Twitter: @stewgleadow
  • 3. What makes a class easy to maintain?
  • 6. What makes a controller easy to maintain?
  • 9. UIViewController - (id)init; - (void)loadView; - (void)viewDidLoad; - (void)viewWillAppear:(BOOL); - (void)viewDidAppear:(BOOL); - (void)viewWillDisappear:(BOOL); - (void)viewDidDisappear: (BOOL); - (void)viewDidUnload; - (void)dealloc;
  • 10. UIViewController - (id)init; - (void)loadView; - (void)viewDidLoad; - (void)viewWillAppear:(BOOL); - (void)viewDidAppear:(BOOL); - (void)viewWillDisappear:(BOOL); - (void)viewDidDisappear: (BOOL); - (void)viewDidUnload; - (void)dealloc;
  • 11. UIViewController - (id)init; - (void)loadView; - (void)viewDidLoad; - (void)viewWillAppear:(BOOL); - (void)viewDidAppear:(BOOL); - (void)viewWillDisappear:(BOOL); - (void)viewDidDisappear: (BOOL); - (void)viewDidUnload; - (void)dealloc;
  • 13. - (id)init; { if ((self = [super init])) { // create data related objects } return self; } - (void)dealloc; { // release any data related objects [super dealloc]; }
  • 15. - (void)loadView; { [super loadView]; // create all your views // assign delegates } - (void)viewDidUnload; { // release any view related [super viewDidUnload]; }
  • 17. @interface MatchViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate, TTModelDelegate, ...>
  • 18. Coordinated Views View One View Two View Three
  • 19. Coordinator - (id)init; - (UIView *)view; - (void)releaseView; - (void)dealloc;
  • 21. 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;
  • 22. 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;
  • 23. 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;
  • 24. Demo

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: \n
  • #5: - small classes\n- small methods\n- single responsibility\n- not much logic, just decoupling\n
  • #6: - nav controller push/pop\n- low memory conditions (recycle the views)\n\n
  • #7: - nav controller push/pop\n- low memory conditions (recycle the views)\n\n
  • #8: \n
  • #9: \n
  • #10: \n
  • #11: \n
  • #12: - 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
  • #13: - automatic layout in full width horizontal\n- independent sections of the screen\n
  • #14: - simplified view controller\n- managed the creation of the view (holds it)\n- hides callbacks (can&amp;#x2019;t use UIView for that)\n
  • #15: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #16: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #17: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #18: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #19: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #20: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #21: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #22: - same object lifecycle, for delegate callbacks\n- simpler view lifecycle\n- automatic layout using stacked view\n
  • #23: \n
  • #24: \n