SlideShare una empresa de Scribd logo
1 de 25
Avoiding oversized
 view controllers
      in iOS

 Stewart Gleadow
 Email:
 sgleadow@thoughtworks.com

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


UIViewController


                   Model
What makes a
controller easy to
    maintain?
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;
- (id)init;
{
  if ((self = [super init]))
  {
    // create data related objects
  }

    return self;
}

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

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

    // create all your views

    // assign delegates
}

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

    [super viewDidUnload];
}
@interface MatchViewController : UIViewController

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

       View One



       View Two




       View Three
Coordinator

- (id)init;

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

- (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;
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

Más contenido relacionado

Similar a iOS View Coordinators

UIViewControllerのコーナーケース
UIViewControllerのコーナーケースUIViewControllerのコーナーケース
UIViewControllerのコーナーケース
Katsumi Kishikawa
 
Apple Templates Considered Harmful
Apple Templates Considered HarmfulApple Templates Considered Harmful
Apple Templates Considered Harmful
Brian Gesiak
 
Utilising View Controllers
Utilising View ControllersUtilising View Controllers
Utilising View Controllers
danielctull
 
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
Ontico
 
iOS: Implementing a Custom View
iOS: Implementing a Custom ViewiOS: Implementing a Custom View
iOS: Implementing a Custom View
Jussi Pohjolainen
 

Similar a iOS View Coordinators (20)

Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
 
I os 11
I os 11I os 11
I os 11
 
UIViewControllerのコーナーケース
UIViewControllerのコーナーケースUIViewControllerのコーナーケース
UIViewControllerのコーナーケース
 
NongBeer MVP Demo application
NongBeer MVP Demo applicationNongBeer MVP Demo application
NongBeer MVP Demo application
 
iOS
iOSiOS
iOS
 
ITB2016 Converting Legacy Apps into Modern MVC
ITB2016 Converting Legacy Apps into Modern MVCITB2016 Converting Legacy Apps into Modern MVC
ITB2016 Converting Legacy Apps into Modern MVC
 
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
 
Apple Templates Considered Harmful
Apple Templates Considered HarmfulApple Templates Considered Harmful
Apple Templates Considered Harmful
 
Utilising View Controllers
Utilising View ControllersUtilising View Controllers
Utilising View Controllers
 
Using view controllers wisely
Using view controllers wiselyUsing view controllers wisely
Using view controllers wisely
 
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
 
iOS: Implementing a Custom View
iOS: Implementing a Custom ViewiOS: Implementing a Custom View
iOS: Implementing a Custom View
 
View controller life cycle
View controller life cycleView controller life cycle
View controller life cycle
 
Daniel Jalkut - dotSwift 2019
Daniel Jalkut - dotSwift 2019Daniel Jalkut - dotSwift 2019
Daniel Jalkut - dotSwift 2019
 
Building impressive layout systems with vaadin
Building impressive layout systems with vaadinBuilding impressive layout systems with vaadin
Building impressive layout systems with vaadin
 
iOS_Presentation
iOS_PresentationiOS_Presentation
iOS_Presentation
 
Koin
KoinKoin
Koin
 
iOSインタラクションデザイン
iOSインタラクションデザインiOSインタラクションデザイン
iOSインタラクションデザイン
 
PhotoFlipCardView
PhotoFlipCardViewPhotoFlipCardView
PhotoFlipCardView
 
Routing to components
Routing to componentsRouting to components
Routing to components
 

Más de sgleadow

Más de sgleadow (11)

Evolving Mobile Architectures @ Mi9
Evolving Mobile Architectures @ Mi9Evolving Mobile Architectures @ Mi9
Evolving Mobile Architectures @ Mi9
 
Evolving for Multiple Screens
Evolving for Multiple ScreensEvolving for Multiple Screens
Evolving for Multiple Screens
 
Mobile: more than just an app
Mobile: more than just an appMobile: more than just an app
Mobile: more than just an app
 
Evolving Mobile Architectures
Evolving Mobile ArchitecturesEvolving Mobile Architectures
Evolving Mobile Architectures
 
Building mobile teams and getting a product to market
Building mobile teams and getting a product to marketBuilding mobile teams and getting a product to market
Building mobile teams and getting a product to market
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 
iOS app case study
iOS app case studyiOS app case study
iOS app case study
 
Frank iOS Testing
Frank iOS TestingFrank iOS Testing
Frank iOS Testing
 
Multithreaded Data Transport
Multithreaded Data TransportMultithreaded Data Transport
Multithreaded Data Transport
 
A few design patterns
A few design patternsA few design patterns
A few design patterns
 
GPU Programming
GPU ProgrammingGPU Programming
GPU Programming
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

iOS View Coordinators

  • 1. Avoiding oversized view controllers in iOS Stewart Gleadow Email: sgleadow@thoughtworks.com Twitter: @stewgleadow
  • 2.
  • 3. What makes a class easy to maintain?
  • 5.
  • 6. What makes a controller easy to maintain?
  • 7.
  • 8.
  • 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;
  • 12.
  • 13. - (id)init; { if ((self = [super init])) { // create data related objects } return self; } - (void)dealloc; { // release any data related objects [super dealloc]; }
  • 14.
  • 15. - (void)loadView; { [super loadView]; // create all your views // assign delegates } - (void)viewDidUnload; { // release any view related [super viewDidUnload]; }
  • 16.
  • 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;
  • 20.
  • 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

Notas del editor

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