So you've been using Core Data in your apps and think it's great and simple and super powerful. But now you're starting to run into problems with your apps that you can't explain and possibly even performance issues. This session will cover some of the more advanced topics about Core Data including doing things in the background (concurrency), caching data, migrating schemas, and dealing with undo management.
5. CORE DATA IN 30 SECONDS
•
Object Graph Store
•
Abstracts Persistence
•
Provides a lot for doing a little
•
Validation, faulting, paging, querying, versioning
8. WHEN DO I WORRY?
👉 Core Data 👎
•
Stuttering / Instruments
•
Asynchronous operations
•
Batch processing
•
Future-proofing app architecture
9. THREADING CAVEATS
•
NSManagedObjects belong to a single context
•
Do not share between threads/contexts
•
Pass by NSManagedObjectID
•
[[managedObject objectID] isTemporaryID]
10. IN THE BACKGROUND
•
Thread containment
•
Queues
•
Multiple contexts
•
Single persistent store coordinator
11. THREAD CONTAINMENT
•
Each thread gets its own
context
•
Manually manage contexts
•
Merge in changes from
NSManagedObjectContext
DidSaveNotification
14. PREFERRED SETUP
•
Primary: Private Queue
•
UI: Main Queue as child of
Primary
•
Background: Private Queue
as child of Primary
•
Allows for asynchronous
saves
http://floriankugler.com/blog/2013/4/2/the-concurrent-core-data-stack
28. INFER MAPPING MODEL
•
Not a silver bullet
•
Model upgrades can skip versions
•
Does not merge multiple versions
•
Business logic between upgrades is lost
32. MANUAL MAPPING
•
More complex scenarios
•
Mapping model is for specific version to version
•
Multiple version change not support unless
sequential migrations used
•
Code is needed for sequential migrations
43. REFERENCES
•
Core Data Programming Guide - Apple
This documentation is seriously out of date.
No really.
It’s bad.
•
Core Data 2nd Ed - Marcus Zarra