Successfully reported this slideshow.

Core Data in Modern Times

0

Share

1 of 28
1 of 28

Core Data in Modern Times

0

Share

Download to read offline

Talk at the CocoaHeadsNL 20150820
Core Data, a comparison to some competitors, some details about concurrency and their implications on todays applications, and some concerns about the future.

Talk at the CocoaHeadsNL 20150820
Core Data, a comparison to some competitors, some details about concurrency and their implications on todays applications, and some concerns about the future.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Core Data in Modern Times

  1. 1. Core Data in Modern Times Jorge D. Ortiz-Fuentes @jdortiz #CoreDataMT
  2. 2. A Canonical Examples production #CoreDataMT
  3. 3. Agenda ★ Background info ★ Comparisons • Realm • Android Content Providers ★ Concurrency in Core Data ★ Threats to Core Data ★ Protect yourself
  4. 4. Background Info
  5. 5. Core Data concepts ★ Data persistence • Objects <-> Data ★ Relationships • 1-1 • 1-M • M-M ★ Store independence
  6. 6. Core Data Persistent Store Persistent Store Persistent Store Coordinator Managed Object Model Managed Object Context MO MO MO MO MO
  7. 7. Core Data Virtues ★ Visual model ★ Seamless integration with Objective-C ★ Relationships, deletion rules, Faulting & Uniquing ★ Undo management and Change tracking ★ KVC & KVO ★ Filtering, sorting, grouping ★ Versioning and migration ★ Merge policies
  8. 8. FetchedResultsController Anatomy ★ iOS only ★ Controller • uses a fetch request • coordinates getting data and caches them • notifies of changes
  9. 9. Bindings ★ OS X only ★ Sync UI and Coredata ★ Reduce the amount of code required
  10. 10. Comparisons are odious
  11. 11. Realm
  12. 12. Realm: Pros & Cons ★ Born mobile ★ Models in code(PK) ★ Built in encryption ★ Multi-thread & Multi-process ★ Good performance ★ No delete rules ★ No fine grained notifications (KVO) ★ No null properties ★ No sync solutions
  13. 13. Android Content Providers
  14. 14. Android Content ★ Content providers • Abstract data sources • Access to data via URI (REST style) • It can be exported to other apps • Thread safety via synchronized (or multi- instance) ★ Content resolver to map authorities to providers
  15. 15. Concurrency in Core Data
  16. 16. Background Queue Main Queue Single process approach ★ Context • Private • MainQueue ★ Nested contexts • Save pushes changes to parent (no I/O) • Parent saves in the background child MOC pStore parent MOC
  17. 17. Good practices ★ Avoid premature optimization ★ Have a police for when to use concurrency ★ Really follow 1 & 2
  18. 18. Also available now ★ Batch updates (Brent Simmons’ problem) ★ Asynchronous fetching
  19. 19. UIManagedDocument ★ Uses the model in the bundle ★ Async I/O ★ Completion blocks after opening or saving ★ Parent is in background and autosaves ★ Also additional data
  20. 20. Threats to Core Data
  21. 21. Threats ★ Swift • Introspection is still half baked (@NSManaged) • Many features of Cocoa depend on the runtime ★ Lack of multi-process capabilities ★ Apple generated doubts: • Photos using • Removed from Lister?
  22. 22. Protect yourself
  23. 23. – Robert C Martin (Uncle Bob) “The database is a detail!”
  24. 24. Clean Architecture View (VC) Presenter Wireframe Interactor Repository Persistence WSC
  25. 25. canonicalexamples.com coupon: COCOAHEADSNL
  26. 26. Thank you!
  27. 27. @jdortiz #CoreDataMT

×