Core Data
Core Data manages an object graph and persists it, usually to SQLite, through contexts and fetch requests. Interviewers use it to test whether you see past the database-wrapper myth.
on this pageshowhide
explore
- Managed Object Model5 questions
- Persistent Stack Setup5 questions
- Managed Object Contexts6 questions
- Fetch Requests & Predicates5 questions
- Relationships & Faulting6 questions
- Migrations & Versioning6 questions
questions
page 2 of 2As the lead of a Core Data app with many shipped model versions, which rules keep every version migratable, and when would you adopt staged migration?
basics
~20 sFreeze shipped model versions, add one version per schema change, review renames, new mandatory attributes and moved values, and test saved stores from each shipped version. Adopt staged migration once the deployment target is iOS 17; below it, mapping models carry custom steps.
In Core Data, how does a mapping model with an NSEntityMigrationPolicy subclass turn each album's free-text artist into a shared Artist entity during migration?
basics
~20 sAdd a mapping model from version 2 to version 3 and set the Album entity mapping's custom policy to an NSEntityMigrationPolicy subclass. Its createDestinationInstances(forSource:in:manager:) calls super, then finds or creates the matching Artist and links the new album to it.
In Core Data, how do you ship a read-only product catalogue store beside the user's own store in one NSPersistentContainer?
basics
~20 sSplit the entities into two model configurations, give the container one NSPersistentStoreDescription per store with its configuration name, and mark the bundled catalogue's description isReadOnly. Core Data routes each fetch and save to the store whose configuration holds the entity.
showing 31–33 of 33