iOS Developer Interview: Questions and Tasks

Timi Stark
5 min readSep 10, 2022

--

In this article, we have collected questions and tasks that are often found in iOS developer interviews.

Questions for iOS Developers

Optional ❓

What is optional? What ways do you know to expand optional? What is an implicitly unwrapped optional?

The optional type in Swift is an enum that can have one of two values: None or Some(T), where T is any data type. With it, you can protect yourself from trying to access a nil value.

There are several ways to expand an optional.

1. Check for nil:

let a: String? = “string”
if a != nil {
print(a!)
} else {
print(“Error”)
}

2. Guard let:

guard let a = a else { return }

3. If let:

if let a = a {
print(a)
} else {
print(“Error”)

4. Force unwrapping is an unsafe way, if the value is nil, the program will end:

print(a!)

5. Nil coalescing:

print(a ?? “Error”)

6. Optional chaining:

print(a?.uppercased())

Optional is also used in type casting:

let b = (a as? int) // b will be nil if a cannot be converted to int
let b = (a as! Int) //if a cannot be converted to Int, the program will terminate

And in error handling:

enum CountError: Error {
case invalidCount
}
func setCount(_count: Int) throws {
if count <= 0 { throw CountError.invalidCount }
// Do things with speed
}
if let success = try? setCount(5) {
print(“Setting speed was successful!”)
}
let fail = try! setCount // similar to force unwrapping

Multithreading 👯‍♀️

You can read about it in the article about GCD and Dispatch Queues.

Differences between frame and bounds ⛔️

This is one of the favorite questions in iOS interviews. The coordinates of the bounds rectangle are counted from its coordinate system, and the frame coordinates are counted from the container in which it is located (superview).

Programming patterns

  • Creational Patterns
  • Structural Patterns
  • Behavioral Patterns.

I also recommend that you study the main architectural patterns that are used for iOS — MVC, MVP, MVVM, VIPER.
I will talk about these patterns in future articles.

Differences between a structure and a class 👽

Structures:

  • value type;
  • have elementwise initializers.

Classes:

  • reference type;
  • can be inherited;

Weak reference 😿

When should you use weak links? What is the difference between weak and unowned?

Weak references are used when an object may not exist at the time the reference is accessed. For example, when accessing self from a closure:

let closure = { [weak self] in
self?.doSomething() //weak reference are optional
}

Weak references, like unowned references, do not increase the reference count. The difference with unowned is that it is not optional. Weak is used when the reference is known to be nil. Unowned — if we know that the reference will never be nil.

Application life cycle 🚲

  • Not Started: The application did not start or was terminated by the system.
  • Inactive: The application is running, but is not currently responding to events (but can execute code). Usually this state does not last long and is intermediate.
  • Active: The application is running and responding to events.
  • Background: The application is running in the background. Most applications stay in this state for a short time before being suspended. However, an application that has requested additional background time may remain in this state for some time. Some applications may run in the background most of the time.
  • Suspended: The application is in the background and is not executing code. The system puts applications into this state automatically, without prior notice. In this state, the application is still in memory but cannot execute code. When low memory occurs, the system may clean up suspended applications without prior notice to make more space available for active offers.

ViewController Life Cycle 🚲

  • init: initializing our controller
  • loadView: used when the controller is created in code. loadView is called by the controller when its current view is nil.
  • viewDidLoad: Called once per controller life. The method executes when all views are loaded.
  • viewDidLayoutSubviews: called when any view changes.
  • viewDidAppear: Called when the view appears on the screen.
  • viewDidDisappear: Called when the controller’s view is removed.
  • deinit: deinitialization and removal of the controller from memory

Access Modifiers ❌

  • public and openopen allows you to inherit and overload classes and class members inside and outside the module. public — only inside the module.
  • internal — access within the module.
  • fileprivate — access within a file.
  • private — access within the entity where the object is defined.

What works faster — search in NSArray or NSSet? 💨

NSSet lookups will be faster because sets, like dictionaries, use hashes.

Defer keyword 🧐

With defer, we can unconditionally execute a block of code before its scope ends. For example:

func readFile(file) {
letfile = openFile(file)
defer { closeFile(file) } //the code in the defer block will be executed after return, whenever it fails
guard let openedFile = file else { return }
}

Tasks for iOS Developers 🫵

It is useful to make tasks from the list in advance and put them on GitHub. Often, such tasks are offered to be done before an iOS interview. Having a ready-made option will save you time.

  • Application with authorization for any public API.
  • Application with a list of tasks: tasks are stored locally, implement editing, adding pictures.
  • Simple Instagram: implement getting a list of pictures from any public API. Images should load as the page scrolls. Clicking on an image opens it in full screen. It is also necessary to use caching so that in the absence of the Internet, the pictures continue to be displayed.
Thank you for viewing the article. 
Subscribe so you don’t miss anything ❤️👨🏻‍💻
My links 🔗:
Youtube 🎥: https://bit.ly/3eBDWM1
Instagram 🖼: https://bit.ly/3Bb5DCZ

--

--

Timi Stark

iOS Engineer 👨🏻‍💻 💎 Don't forget to subscribe Youtube my channel https://bit.ly/3eBDWM1 ❤️