iOS Developer interview question

How do you choose local persistence in iOS?

Choose persistence from data shape, volume, query and sync needs: UserDefaults for small preferences, files for blobs, Keychain for secrets, and SwiftData/Core Data or SQLite for structured relationships.

Direct answer

What a strong answer covers

How it works

The store follows the data. Small user preferences and flags belong in UserDefaults. Secrets such as tokens belong in the Keychain, which survives reinstall and is encrypted by the system. Large blobs such as downloaded media go to the file system under Caches if regenerable or Application Support if not, with file protection attributes. Structured, related, queryable data belongs in SwiftData or Core Data, which give change tracking, migrations, and iCloud sync, or in SQLite through GRDB when full control over SQL matters. Mixing tiers is normal: the database stores metadata and a path to the file.

Example

A podcast app keeps playback speed in UserDefaults, the subscription token in the Keychain, episode audio in Caches with a size-managed eviction policy, and the episode catalogue with listening progress in SwiftData so the library view can query unplayed episodes per show. An earlier version stored progress as a JSON file that was rewritten entirely on every update and became slow and fragile.

Common mistakes

  • Serialising the whole app state to one JSON file and rewriting it constantly.
  • Putting large data in UserDefaults and slowing app launch.
  • Choosing Core Data for a handful of settings and adding migrations for nothing.

A useful answer structure

Answer from your own work.

Do not memorise a script: use only examples you can explain honestly in follow-up questions.

Practise this answer with MiraHint

Open the desktop workspace and rehearse a clear answer in your own words.

Download MiraHint
iOS Developer interview questions