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
I recently got into the position of leading the technical interview when my client was searching for a new senior iOS developer.
It's a challenging task to evaluate the skills and knowledge of another developer. So in this post, I want to share my results of the most useful iOS and Swift questions and answers with you. I categorised the questions into different topics:
- Swift Programming Language (covered in part 1)
- Networking (covered in part 2)
- Persistence & Databases (covered in this post)
- Concurrency (covered in part 4)
- Architecture & Design Patterns (covered in part 5)
- Testing (covered in part 6)
- Continuous Integration (coming soon)
This post covers questions and answers on persistence & databases.
The purpose of these interview questions is to get to know the developers general knowledge of database concepts. And also to check their specific knowledge on persistence in iOS.Squirrels have a lot of experience when it comes to storing items. They are able to retrieve up to 95 percent of their buried food, all from their memory.
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 Part 6 - 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 Part 5 - 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