Logo for tanaschita.com

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.

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?

UserDefaults is a great way to save a small amount of data. You can store basic types such as Bool, Int, String etc., and also more complex types like arrays and dictionaries.

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.

Related tags

Written by

Articles with related topics