10 Most Asked Questions for iOS Developer (Swift) Interview with Answers

Yalçın Özdemir
4 min readNov 15, 2018

--

I have been to many iOS Developer specific interviews and I was asked to explain a lot of stuff instead of writing any code. You may know how to build apps or be an expert in writing Swift code, but that doesn't mean you will do good in your iOS Developer interviews. Most companies don’t let you write apps or even code when they hire you, they simply ask direct questions and they want the descriptions. Therefore, make sure you understand what you use when you are developing your apps. Here are 10 questions that I was asked during my iOS Developer interviews. I have collected the answers from the books and online recourses, combined them together on one page, so you won’t have the same struggles as me.

1. What is Memory Management and ARC?

A program needs to allocate and deallocate memory as needed. Swift does that automatically. Swift does not use a garbage collector which is a common tool. ARC is Automatic Reference Counting introduced for Obj-C.

Everything is automatically managed, but you need to know ARC to avoid memory leaks.

Retain Cycles?

Retain cycles happens when a reference is pointing to another reference so it will never be removed from the heap.

This mostly happens in classes and closures. Closures live in memory, so when you use Self which is a reference you need to make sure that you solve the retain cycle.

Weak, unowned, strong?

Unless you specify otherwise, all Swift properties are strong, which means they will not be removed from RAM until whatever owns them is removed from RAM.

Weak on the other hand is there when you want to say “I want to be able to reference this variable, but I don’t mind if it goes away, so I don’t want to own it.” This might seem strange: after all, where’s the point in having a reference to a variable that might not be there?

Unowned means “don’t mind this one, I will make sure it is removed from memory.”

2. What is MVC & Other Design Patterns You Use?

Model-View-Controller is a design pattern based on three job categories: model, view or controller.

Model: Models are responsible for storing data and making it available to other objects.

View: Views are the visual elements of an application. What you see on screen.

Controllers: Controllers perform the logic necessary connect your views and models. They process events.

You may use different kinds of design patterns when you are developing your apps, but here are the most common ones.

Singleton: The Singleton design pattern ensures that only one instance exists for a given class

Singleton Plus: you can create another object. Doesn’t force you to use the shared one.

Facade: The Facade design pattern provides a single interface to a complex subsystem. Let’s say you have NetworkManager class where you make HTTP requests and you have JSON response. With using Facade, you can keep your NetworkManager just focused on networking.

Decorator: The Decorator pattern dynamically adds behaviors and responsibilities to an object without modifying its code.

Adapter: An Adapter allows classes with incompatible interfaces to work together. It wraps itself around an object and exposes a standard interface to interact with that object.

Observer: In the Observer pattern, one object notifies other objects of any state changes. Cocoa implements the observer pattern in two ways: Notifications and Key-Value Observing (KVO).

3. What is the difference between value types and reference types?

The major difference is that value types are copied when they are passed around, whereas reference types share a single copy of the referenced information.

4. What is an optional in Swift and what problem do optionals solve?

An optional is used to let a variable of any type represent the lack of value. An optional variable can hold either a value or nil any time.

5. What are the main differences between Structures and Classes?

Classes support inheritance, structures don’t. Classes are reference types, structures are value types.

6. What are the various ways to unwrap an optional? How do they rate in terms of safety?

forced unwrapping ! operator — unsafe

implicitly unwrapped variable declaration — unsafe in many cases

optional binding — safe

optional chaining — safe

nil coalescing operator — safe

guard statement — safe

optional pattern — safe

7. What is auto-layout?

Auto layout dynamically calculates the size and position of all the views in your view hierarchy based on constraints placed on those views.

8. What are Higher Order Functions in Swift?

Sort: Sorting arrays

Map: Transform array contents

Filter: Filter array based upon some criteria

Reduce: Reduce the values in collection to a single value

9. What is Lazy Loading?

Lazy loading means the calculation of the property’s value will not occur until the first time it is needed.

10. What is CoreData?

Core Data is a framework for managing an object graph. An object graph is nothing more than a collection of interconnected objects. The framework excels at managing complex object graphs.

Bonus: Differences between Concurrent and Serial Queues?

Concurrent: multiple at the same time

Serial: first come first served, first in first out, ordered

--

--