Persistence interview questions
38 questions from real iOS interviews. Topics: Core Data, SwiftData, UserDefaults, files, migrations, sync.
- PersistenceShort answer
UserDefaults scope and limits
A teammate's PR stores the access token, the profile image Data, and an array of 5,000 recently viewed products all in UserDefaults. What would you raise in re…
#userdefaults #plist #storage
- PersistenceMultiple choice
Atomic file writes
A notes app saves Data to Documents/notes.json. Select all the correct statements about file writes. …
#filemanager #data-write #atomic #documents
- PersistenceShort answer
Picking a local store
A new iOS project has to store a favorites list, the login session, downloaded PDFs, and display settings locally. Which store would you pick for each?
#storage-choice #userdefaults #keychain #filemanager
- PersistenceMultiple choice
Keychain characteristics
Compared with UserDefaults, select all the correct characteristics of the Keychain.
#keychain #security #userdefaults
- PersistenceMultiple choice
Choosing a directory
You want to store a few thousand thumbnail images locally that you can download again at any time. Which directory fits best?
#filemanager #caches #documents
- PersistenceShort answerHeadspace
Persistence tools you've used
This is a written question on a take-home: "Which tools have you used to persist data so far?" Answer with what data you used each tool for and why, not with a…
#userdefaults #keychain #swiftdata #file-storage
- PersistenceShort answer
Choosing Core Data
Which requirements push you to Core Data (or SwiftData) instead of UserDefaults or a plain file?
#core-data #swiftdata #sqlite #storage-choice
- PersistenceShort answer
Core Data stack setup
You have a bug where a screen backed by Core Data adds an item but the list never updates. Where is that bug most likely coming from?
#core-data #nspersistentcontainer #nsmanagedobjectcontext #nsfetchrequest
- PersistenceMultiple choice
Context threading rules
This is a news app on Core Data. You fetched an Article on a background context (container.newBackgroundContext()), handed the object straight to a view on the…
#core-data #threading #nsmanagedobjectid #background-context
- PersistenceShort answer
Core Data vs SQLite
A teammate says "Core Data is heavy and hard to understand, let's use SQLite directly (or GRDB)." What's the real difference between the two approaches?
#core-data #sqlite #grdb #realm
- PersistenceShort answer
Archiving and plists
Legacy code saves model objects to a file with NSKeyedArchiver, and on recent OS versions unarchiving started warning and crashing. What's the difference betwe…
#nscoding #nssecurecoding #nskeyedarchiver #plist
- PersistenceMultiple choice
Relational vs object DB
Select all the sound reasons to pick a SQLite-backed relational store (Core Data, SwiftData, GRDB) over a document or object database such as Realm for an iOS …
#sqlite #nosql #realm #rdbms
- PersistenceMultiple choice
NSFetchedResultsController
On a Core Data list screen, what does NSFetchedResultsController do, most precisely?
#core-data #nsfetchedresultscontroller #uitableview
- PersistenceShort answer
SwiftData building blocks
Say you're building a to-do app with SwiftData. What do @Model, ModelContainer, ModelContext, and @Query each do?
#swiftdata #model #modelcontainer #modelcontext
- PersistenceMultiple choice
SwiftData facts
Select all the correct statements about SwiftData.
#swiftdata #model #core-data
- PersistenceShort answer
Sandbox directories and backup
Users complain that the app takes up 2GB of their iCloud backup, and review flagged you on the offline data storage guideline. Walk me through the app sandbox …
#filemanager #documents #caches #tmp
- PersistenceShort answerBloomberg
Server and local models
A phone screen asked how you design data models on the backend and how you handle them on mobile. If you use the server's response JSON structure as your local…
#dto #domain-model #swiftdata #schema-evolution
- PersistenceShort answerPhonePe
Keychain access groups
Two payment apps from the same team, the main app and a merchant app, have to share one login token. UserDefaults and files are out, so on what conditions and …
#keychain #access-group #entitlements #app-group
- PersistenceShort answerByteDance
NSCache vs custom LRU
NSCache exists, so why do image libraries write their own LRU cache?
#nscache #lru #linked-list #image-cache
- PersistenceMultiple choiceShopee
LRU behavior and structure
You picked LRU for an image cache. Select all the correct statements about LRU.
#lru #cache #hit-rate #linked-list
- PersistenceShort answerAlibaba Group
ObjC runtime model mapping
In the Objective-C days, YYModel and MJExtension turned JSON into models and even handled NSCoding archiving from nothing but the class definition. Which runti…
#objective-c #runtime #kvc #codable
- PersistenceShort answer왓챠interview report
Realm vs Apple stack
A legacy app leans on Realm heavily. As the new hire you're asked whether to stay on Realm or move to SwiftData/Core Data. How do Realm's threading and object …
#realm #swiftdata #core-data #threading
- PersistenceMultiple choiceCapital Oneinterview report
Matching stores to requirements
Select all the pairs where a finance app's storage requirement is matched with the right store.
#storage #userdefaults #keychain #caches
- PersistenceShort answer
Core Data migration
You shipped an update to a Core Data app and crash reports are pouring in. The log says "The model used to open the store is incompatible with the one used to …
#core-data #migration #lightweight-migration #mapping-model
- PersistenceMultiple choice
Lightweight migration scope
Select all the changes Core Data handles with lightweight migration, with no mapping model.
#core-data #migration #lightweight-migration
- PersistenceShort answer
Faulting and save
You fetched 10,000 objects from Core Data and memory barely moved, and then it grows a little as you scroll the list. Explain what's going on inside.
#core-data #faulting #nsmanagedobject #save
- PersistenceShort answer
SwiftData schema migration
You shipped a SwiftData app and now want to add a priority field to Todo and clean up existing title values by trimming whitespace. Which change happens automa…
#swiftdata #migration #versionedschema #schemamigrationplan
- PersistenceShort answer
Data Protection classes
You have logs where the app, woken by a background push while the screen is locked, fails to open its local database. What is file protection (Data Protection)…
#data-protection #file-protection #encryption #background
- PersistenceShort answer
Background saves and merging
You have two complaints: data saved on a background context doesn't refresh the main screen, and the other way around, values being edited on main get overwrit…
#core-data #background-context #merge #automaticallymergeschangesfromparent
- PersistenceMultiple choice
Merge policy behavior
This is a notes app on Core Data. A background context changed note.body to the server's value and finished saving first. The main context, which doesn't know …
#core-data #mergepolicy #conflict
- PersistenceMultiple choicePhonePe
Contexts for parallel downloads
You're downloading image metadata in parallel on four threads and saving it to Core Data. Select all the correct statements about how many NSManagedObjectConte…
#core-data #managed-object-context #background-context #merge
- PersistenceShort answerZomato
Key-value store with expiry
You're given 15 minutes to design a key-value store whose values carry an expiry time. set(key, value, ttl) and get(key) must never hand back an expired value,…
#userdefaults #ttl #sqlite #index
- PersistenceShort answer당근interview report
Offline chat storage design
Chat in a secondhand marketplace app has to work for reading and writing on the subway. Design the local database schema and the sync flow so that messages sen…
#offline-first #chat #outbox #sync
- PersistenceMultiple choicePinduoduo
LFU cache characteristics
Someone proposes moving the image cache from LRU to LFU. Select all the correct statements about LFU.
#lfu #lru #cache #eviction
- PersistenceShort answer
CloudKit sync constraints
You want to add iCloud sync across devices to a SwiftData/Core Data app that has been local only. What do you have to change in the schema and the design befor…
#cloudkit #nspersistentcloudkitcontainer #swiftdata #sync
- PersistenceShort answer
Bulk insert performance
An initial sync saves 100,000 records into Core Data, memory climbs to 1GB and the app gets killed, and the UI freezes the whole time. What do you think the ca…
#core-data #nsbatchinsertrequest #performance #memory
- PersistenceMultiple choice
Store sharing with extensions
You want a widget extension to read the main app's SwiftData/Core Data store. Select all the correct statements.
#app-group #widget #sqlite #persistent-history
- PersistenceShort answer
Server sync design
You need to sync a notes app's local database with the server. Downloading everything each time is slow and burns data. How would you design a delta sync proto…
#sync #delta-sync #tombstone #offline