Top 50 iOS interview questions for Senior Software Engineer(August-2023)

Heena Mulla
7 min readAug 30, 2023

--

Photo by krakenimages on Unsplash

Most of us feel overwhelmed and anxious before a job interview. Preparation ahead of time will help you perform at your very best. After going through several interviews for iOS Senior software Engineer position and cracking few of them, I thought of sharing my notes, so that it can be helpful for others too.

In this article, we will discuss top 50 iOS/Swift interview questions with short explanations, which will help you to prepare for iOS/Swift interview. You can prepare your own answers for these following questions. Try to answer in short and if asked then only explain in details with a valid example. So let’s begin !!!

  1. Explain SOLID Principles (S — Single responsibility, O — Open-Closed, L — Liskov Substitution, I — Interface Segregation, D — dependancy Inversion)
  2. Tell us few commonly used design patterns in iOS( Discuss about MVC, MVVM and VIPER architecture followed by Singleton, Delegates, Observer etc.)
  3. Explain Memory management ( Explain about ARC — Automatic reference counting)
  4. Difference of strong, weak and unowned. ( strong — Increase retain cycle by 1, weak — does not increase retain cycle by 1 but should be optional, unowned — does not increase retain cycle by 1 but can not be optional)
  5. What is circular reference cycle?( when two instance hold strong reference to each other causing a memory leak. Solve it by making one of the references as weak)
  6. Explain Clean coding architecture a.k.a. VIP (V — View, I — Interactor and P — Presenter, these three will have unidirectional communication between them using ViewModel i.e, View to Interactor, Interactor to Presenter and Presenter to View)
  7. Explain the use of “actor” in detail. (Provides actorIsolation i.e, properties and methods can not be read from outside the actor object unless they are performed async and stored properties can not be written from outside the actor object at all)
  8. What is the use of “Global Actor” in swift? (using @MainActor keyword, we can make sure that the task performs on main thread)
  9. What is closure?(Block of functionality that are fully self contained. We can use them without “func” keyword)
  10. What are the different ways of using closure? ( Explain @escaping and @nonescaping closure, followed by trailing and autoclosure)
  11. What is the capture list of closure? ( It creates a copy of a variable, when you declare the closure)
  12. What is closure retain cycle? How to avoid it?(When we access self inside a closure, it creates strong reference to each other and there will be memory leak. To avoid always use [weak self] inside a closure)
  13. Sequence of UIKit View Controller lifecycle.(LoadView>ViewDidLoad>ViewWillAppear>ViewDidAppear>ViewWillLayoutSubview>ViewDidLayoutSubview>ViewWillDisappear>ViewDidDisappear)
  14. What is protocol?(Defines a list of optional and required methods that a class can/must implement to adopt it)
  15. Explain Hashable Protocol use.(Protocol that provides a hashable values to our object, which we can use to compare the object with same values)
  16. What are the higher order functions?(Simply functions that operates on other functions, by either taking a function as an arguments or returning functions. Ex. sorted, sorted(by:), map, filter, reduce)
  17. What is generic, explain with example?(Helps to write a generic and reusable code, avoiding duplicates)
  18. What are the different constraint we can use on generic?( CustomStringConvertible, Numeric, comparable, Equatable, NotEquatable etc)
  19. Explain optional chaining and optional binding.(Optional Chaining — when we calling any properties, method and subscript an optional values which may contain nil. Optional binding — When we access optional properties, instead of force unwrapping if we check it’s value)
  20. Use of “defer” keyword. (Used to create a defer block inside a function, which will be execute before leaving the function current scope)
  21. Difference between struct and class. (Struct — value type, no inheritance supported, uses stack memory(fast), no deinit. Class — reference type, inheritance supported, uses heap memory, deinit)
  22. Difference of some and any keyword.(some — Indicates a box whose contained value has a type known to compiler at compile time. any — Indicates a box whose contained value has a type not known to compiler at compile time)
  23. What is enum? (class type containing a group of related items under the same umbrella, but it is impossible to create it’s instance)
  24. What is the difference of raw value and associated value of enum?(Raw values of enum are value given to every case ex. case jan = 1, whereas associated value will be a parameter passed to the case ex. case jan(day: Int))
  25. Difference of default and @unkown default keyword in enum?(default covers the remaining all cases of an enum whereas @unknown default will always give warning that all cases are not used. @unkown default will be useful when you add new value to enum and want to receive a warning)
  26. Use of “lazy” keyword.(When a property is called for the first time, an initial value of it is calculated)
  27. What do you mean by Opaque type in swift?(used to return some value for function/method and property without revealing the concrete type of the value to the client that calls the API)
  28. What is the use of “@Objc” keyword in Swift?(This means we want our swift code to be visible from Objective C. There are still Objective C framework, we use while coding in swift)
  29. Difference of static and class variable.(Both are variable which allows to attach a value to a class than to an instance. These values will be common to all the instances of a class. Difference is, in inheritance we can override a class variable but not the static one)
  30. Difference of VIP and VIPER architecture.(Components used in both architecture are almost same i.e, View, Interactor, Presenter, Entity and Router but the communication in VIPER is bi-directional with Presenter with others but in VIP it is uni-directional between V-I-P)
  31. Difference of .popLast() and .removeLast() on Array.(.popLast() can give a nil value if an array is empty but .removeLast() will crash if an array is empty)
  32. What is Swift compilation condition, explain with example.(Use of #if-#else-#endif in code, is called compilation condition. Ex. #if OS(iOS), #if arch(arm64), #if canImport(<Lib Name>) etc.)
  33. What is mutating function and when we use it? (To change the internal value and object of a struct, using an object of struct. With struct, you must mark method that is changing an internal state as “mutating” but you can’t invoke them from immutable variable.)
  34. Use of zip on two array?(Ex. array1 = [1, 2] and array2 = [“One”, “Two”]. By calling zip(array1, array2), we can achieve result as [(1, “One”), (2, “Two”)])
  35. Use of Result block.(Result initialise a block that accepts a throwing function. In this instance the function call will throw an error, causing result to be set to failure with and error)
  36. What is the use of final keyword?(writing final keyword before class, make sure no other class can inherit that class)
  37. Difference of Dynamic dispatch and Static dispatch in iOS.(Dynamic Dispatch — 1. Supported by reference type as needs inheritance 2. will execute at runtime and do all checks 3. have to use @objc dynamic keyword 4. slower Static Dispatch — 1.Supported by both reference and value types 2. will check everything at compile time itself 3. have to use static or final keyword 4. faster)
  38. Difference of “codable” and “decoadable” protocol.(codable protocol allows to fo conversion from json-object and vice versa whereas in decoable only json-object conversion is allowed)
  39. Use of one sided ranges in Array.(Allow us to skip either the start or end of the range to have swift infer the starting point for us)
  40. Explain dependancy injection and it’s type. (Instead of giving our object the responsibility of creating it’s own dependency, we inject them to objevct. This keeps code loosely coupled to test. Types: 1. Property Injection 2. Constructor Injection 3. Method Injection)
  41. Difference of GCD and NSOperationQueue.(GCD — Low level API interact with unix level of system NSOperationQueue — High level Obj-c class that works on top of GCD)
  42. What is QOS in GCD?(QOS — Quality of service, it states priority of the task. Type — 1. User Initiated 2. Utility 3. Background 4. User Interactive)
  43. States of iOS App.(1. Not running 2. Inactive 3. Running 4. Background 5. Suspended)
  44. How to use async-await in Swift.
  45. What is Tuple?(It is a temporary container of multiple values comma separated and enclosed in parentheses)
  46. What are the guard benefits?(1. no nested if-let statements 2. Early exist out of the function using return & break 3. Safely unwrap optional)
  47. Difference of any and anyObject.(They are used to keep the type flexible. Any — Used for value type, reference type, function and closure etc. AnyObject — Used for reference type and object of the class)
  48. What is the use of “reuse identifier”?(To group all the similar rows from UITableView)
  49. Difference of sync and async task?(sync — Start a task and block the calling thread until task is finished. async — Start a task and will directly return on the calling thread without blocking)
  50. What is Iterator Protocol? (It provides the value of a sequence one at a time. It allows you to move through a sequence.)
Photo by Razvan Chisu on Unsplash

Hope this will help you to prepare for iOS interview and get an idea of questions. Please leave a comment, if any question.

--

--