skip to content

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 pageshow

explore

questions

page 2 of 2

As 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?

level: principalimportance: should knowfreq 30%

basics

~20 s

Freeze 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.

open as a page

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?

level: seniorimportance: nice to knowfreq 25%

basics

~20 s

Add 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.

open as a page

In Core Data, how do you ship a read-only product catalogue store beside the user's own store in one NSPersistentContainer?

level: seniorimportance: nice to knowfreq 25%

basics

~20 s

Split 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.

open as a page

showing 31–33 of 33