Daily iOS
Persistence

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

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

UserDefaults isn't encrypted, and the whole plist sits in memory and gets serialized again on every write, so the token belongs in the Keychain, the image in a file, and the 5,000-item array in a database.

Share a question