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

MVVM

 MVVM

In this presentation I implement the MVVM pattern by combining Core Data and Reactive Cocoa. The MVVM pattern can use any data storage and binding libraries, but I chose Core Data and Reactive Cocoa since they are common on iOS. The presentation contains many links. You will need to download the PDF for the links to work. Demo at https://github.com/rob-brown/Demos/tree/master/MVVMDemo.

Rob Brown

April 01, 2014
Tweet

More Decks by Rob Brown

Other Decks in Technology

Transcript

  1. Core Data Layers XML SQLite Binary In Memory Custom NSPersistentStore

    NSPersistentStoreCoordinator NSManagedObjectModel NSManagedObjectContext NSManagedObject Application NSManagedObject Subclass
  2. More on Core Data Intro to Core Data Core Data:

    Data Storage Management for iOS, OS X, and iCloud RBCoreDataStack
  3. What is Reactive Cocoa? Made by GitHub A functional reactive

    programming (FRP) framework Provides the bindings in MVVM
  4. What is Reactive Cocoa? Binds properties together Eliminates the need

    for mutable state UI updates automatically as data changes
  5. Application Stack ViewModel Network ViewController View SQLite Binary In Memory

    Custom NSPersistentStore NSPersistentStoreCoordinator NSManagedObjectModel NSManagedObjectContext NSManagedObject NSManagedObject Subclass XML
  6. Model Represents the data layer Can be built with any

    technology Ex. Core Data, SQLite, JSON, PList, memory-only
  7. View Handles layout and presentation of data In iOS, the

    “View” refers to both UIViews and UIViewControllers
  8. ViewModel An adapter between the View and Model Contains all

    the business logic Uses bindings to pass data around
  9. Benefits of MVVM View models are testable View models can

    be used like models View models are (mostly) platform-agnostic View and view controllers are simpler