Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unburdened ViewControllers

Unburdened ViewControllers

Originally presented at Triangle CocoaHeads on August 23, 2012

When creating large-scale iOS apps, it's very easy to fall into the trap of creating overly complex ViewControllers. This talk described a couple of strategies for delegating that complexity and so that your ViewControllers can focus on their original purpose of coordinating the flow of the application.

83231ffaec4a72ef96d26526872961ac?s=128

Jay Thrash

August 23, 2012
Tweet

Transcript

  1. Unburdened ViewControllers Triangle CocoaHeads - Aug 2012 Jay Thrash ::

    jay.thrash@mac.com :: @jaythrash Saturday, January 18, 14
  2. In the Beginning.. View Controller View Model Model View Saturday,

    January 18, 14
  3. Quickly becomes... Saturday, January 18, 14

  4. Quickly becomes... SOAP REST Core Data Saturday, January 18, 14

  5. Beginning of the End ViewController View Model Model View SOAP

    REST Core Data Saturday, January 18, 14
  6. Saturday, January 18, 14

  7. Open a Store Saturday, January 18, 14

  8. iOS Programming Big Nerd Ranch Guide Saturday, January 18, 14

  9. Store-Controllers CMMotionManager CLLocationManager Saturday, January 18, 14

  10. Model View Controller Store Saturday, January 18, 14

  11. MVC(S) Controller Model External Data Store View Controller Model View

    Saturday, January 18, 14
  12. Store Interface #import <Foundation/Foundation.h> @class CHItem; @interface CHItemStore : NSObject

    { NSMutableArray *items; } // Access the singleton Store + (CHItemStore *)store; // Access Store contents - (NSArray *)allItems; - (void)addItem:(CHItem *)item; - (void)removeItem:(CHItem *)item; // Persist Store contents - (BOOL)save:(NSError *)err; @end Saturday, January 18, 14
  13. Store Responsibilities • Model Objects from Data Sources • Handles

    Loading & Saving of Model Objects • Encapsulates Caching and Lazy Fetching Saturday, January 18, 14
  14. Before & After Store Controller Fetches Models Controls Flow Persists

    Models Get, Update, Insert using Store Encapsulates Saving Requests Saving Caches Data Not concerned with data caching Saturday, January 18, 14
  15. Extra Credit • Asynchronous Data Requests • Memory Management •

    Caching • Lazy Loading Saturday, January 18, 14
  16. Change Your View Saturday, January 18, 14

  17. Third Wheel Controller View Model View External Data Store Model

    Saturday, January 18, 14
  18. Frictionless Controller View Model View External Data Store Model Saturday,

    January 18, 14
  19. Benefits • Reusable Views - Just add a Model •

    ViewController as Conductor • Interface with Store • Handle User’s Input Saturday, January 18, 14
  20. Name Author URL iOS Programming Joe Conway and Aaron Hillegass

    http://www.bignerdranch.com Ubuntu Font Family Canonical, Ltd. http://font.ubuntu.com/ Unburdened ViewControllers Jay Thrash :: jay.thrash@mac.com :: @jaythrash Resources & Attributions Saturday, January 18, 14