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

AFIncrementalStore

 AFIncrementalStore

* Audio of another version of this talk, given at Cocoaconf PDX 2012, is available here: http://soundcloud.com/mattt-thompson/syncing-with-afis

Second to views, networking is the hardest part of iOS programming. And it's several orders of magnitude more difficult if you plan to persist a local copy of the data in Core Data, and keep it in sync with the server. Nevermind the tricky theoretical issues of local cache invalidation and conflict resolution, it's hard enough to get Core Data set up in the first place! At least all of this was true before AFInrementalStore came around. Come learn how AFIncrementalStore works, and in doing so, get a deep dive into Core Data itself.

Mattt Thompson

October 11, 2012
Tweet

More Decks by Mattt Thompson

Other Decks in Programming

Transcript

  1. Core Data • Object Consistency Across Contexts • Faulting Behavior

    • Graphical Data Modeling • Automatic Versioning & Migration
  2. Core Data • Object Consistency Across Contexts • Faulting Behavior

    • Graphical Data Modeling • Automatic Versioning & Migration • 
  3. Core Data HTTP Create Read Update Delete Insert POST Fetch

    / Refresh GET Update PUT / PATCH Delete DELETE
  4. Z_PK Z_ENT Z_OPT ZPOSTID ZUSER Z_AF_RID 1 1 1 2

    1 1 3 1 2 914043 29 /posts/914043 914079 31 /posts/914079 915122 57 /posts/915122
  5. Z_PK Z_ENT Z_OPT ZPOSTID ZUSER Z_AF_RID 1 1 1 2

    1 1 3 1 2 914043 29 /posts/914043 914079 31 /posts/914079 915122 57 /posts/915122
  6. Core Data → HTTP - requestWithFetchRequest: withContext: - requestWithMethod: pathForObjectWithID:

    withContext: - requestWithMethod: pathForRelationship: forObjectWithID: withContext: (Reading)
  7. I. The Server is the Canonical Source of Truth II.

    Be Chatty III. Use HTTP Caching Semantics Philosophy
  8. Features •Integrates with Any Core Data Stack •Encapsulates All Networking

    Logic •Automatically Syncs with Server •Adapts to Any Web Service
  9. Features •Integrates with Any Core Data Stack •Encapsulates All Networking

    Logic •Automatically Syncs with Server •Adapts to Any Web Service •Reasonable Code Base (~600 LOC)