iOS Interview Questions and Answers for Senior Developers Part 3 - Persistence & Databases
Check your knowledge on database concepts and persistence in iOS
01 Nov 2019 · 3 min read
This post is part of a series
iOS Interview Questions and Answers For Senior Developers
I recently got into the position of leading the technical interviews when my client was hiring a new iOS developer. It's a challenging task to evaluate the skills and knowledge of another developer. In this post, I share the results of my most useful iOS and Swift questions and answers.
The purpose of the interview questions in this part is to get to know the developers general knowledge of database concepts. And also to check their specific knowledge on persistence in iOS.
So let's get started.
1. What options to persist data are available on iOS?
Depending on the case and the amount of data, there are different ways to store data. Examples are User Defaults, saving Files, Keychain, Core Data. There are also third party libraries like Realm.
2. In what cases would you use UserDefaults?
3. When would you use the Keychain to store data?
Keychain is a good choice, if you want to save highly sensitive and secure data like passwords, keys etc. When using Keychain, it automatically takes care of data encryption before it is stored in the file system.
4. How would you persist large amounts of data objects with relationships in iOS?
Core Data or Realm Database are often used on iOS to deal with a large amount of data.
Core Data is Apple’s native solution for persistence. Through Core Data’s model editor, you define your data’s types and relationships, and generate corresponding class definitions.
Realm Database is a highly supported open source library that is also available for Android. It is popular because it is easy to use and really fast.
These are not the only options of course. For example, you could also use a SQL database, there are some SQL libraries around, like SQLite.swift.
5. Explain what data migration means and when it needs to be done?
Data migration is often necessary when you need to make changes to the data model. So every time when the data model needs a change, e.g. for a new feature request, you’ll need to create a new version of the data model and provide a migration path.
An alternative to migration is simply deleting and rebuilding the data store. But this is only an option, if the stored user data can fully be restored, e.g. from a backend api.
Articles with related topics
iOS Interview Questions and Answers for Senior Developers - Testing
Check your knowledge on automated tests in Swift and iOS
16 Jan 2021 · 8 min read
iOS Interview Questions and Answers for Senior Developers - Architecture & Design Patterns
Check your knowledge on architecture and design patterns in Swift iOS
02 Sep 2020 · 6 min read
iOS Interview Questions and Answers for Senior Developers Part 4 - Concurrency
Check your knowledge on threading concepts and concurrency in iOS
30 May 2020 · 6 min read
iOS Interview Questions and Answers for Senior Developers Part 2 - Networking
Check your knowledge on general computer networking concepts and networking in iOS
01 Oct 2019 · 5 min read
iOS Interview Questions and Answers for Senior Developers Part 1 - Swift
Check your knowledge on Swift and programming language concepts
15 Jul 2019 · 5 min read