Local Data for iOS Developers
Local data is how an iOS app stores information on the device. SwiftData and Core Data persist structured models with queries and relationships, while the Keychain securely stores secrets such as tokens, and the file system holds documents and caches in sandboxed directories.
Stage: Data and Networking · Part of the iOS Developer roadmap · Last reviewed 19 November 2026
What to learn in Local Data
- Define a SwiftData model and fetch it with a query
- Insert, update and delete objects in a model context
- Store an auth token in the Keychain rather than UserDefaults
- Save and read files in the documents and caches directories
- Plan a schema migration when models change
Local Data interview questions
Why store tokens in the Keychain and not UserDefaults?
UserDefaults stores values in a plain property list that is not encrypted for secrets and can be read from backups or on a compromised device. The Keychain is encrypted, protected by the system and can require the device to be opened with a passcode or biometrics.
What is the relation between SwiftData and Core Data?
SwiftData is a newer Swift-native API built on the same persistence technology as Core Data. It uses macros like @Model and integrates with SwiftUI queries, so it is less verbose, while Core Data remains for older targets and advanced needs.
Where Local Data fits in the iOS Developer roadmap
Local Data belongs to the Data and Networking stage (beginner level), which takes about 6 hours. Persistence and APIs.
Other units in this stage
Back to the full iOS Developer roadmap