iOS Interview Study Guide(shared)

 Quick note:

  • This is a public document to help iOS developers study for interviews. 

  • Feel free to add new questions or expand on existing answers

  • If you have found this at all useful and are looking for a simple way to say thanks, you can check out an app I made for iOS developers and leave a rating, or connect with me on LinkedIn or follow my Github. Cheers!

Classic questions

Object Oriented Programming

  • Definition: type of programming that defines the data types called objects, and also operations called functions that can be applied to the data structure.

  • Pillars

  1. Abstraction: idea of showing only essential features of something to the outside world while hiding any irrelevant information

  2. Encapsulation: used to hide the values or state of a structured data object inside a class, preventing unauthorized parties' direct access to them

  3. Inheritance: Classes can inherit functionality of other classes. This helps reuse and enhance code. 

  4. Polymorphism: Means many forms. For instance a subclass can define its own behavior but still retain the behavior of its parent class such as creating a custom button class that inherits from UIButton

Struct vs a class

What they have in common

  • Define properties to store values

  • Define methods to provide functionality

  • Define subscripts to provide access to their values using subscript syntax

  • Define initializers to set up their initial state

  • Be extended to expand their functionality beyond a default implementation

  • Conform to protocols to provide standard functionality of a certain kinds

Class only

  • Inheritance enables one class to inherit the characteristics of another.

  • Type casting enables you to check and interpret the type of a class instance at runtime.

    • You can use deinitializers to enable an instance of a class to free up resources

  • Reference counting allows more than one reference to a class instance.

  • Use a struct when you want to pass by value, and a class when you want to pass by reference. Classes also allow inheritance.

Difference between frame vs. bounds

  • A view’s frame is it’s coordinates based on it’s super view, whereas it’s bounds is it’s own set of coordinates, with (0, 0) being the top left corner

What is a retain cycle

  • When two objects have strong references to each other, making it so both objects can’t get deallocated. The solution is to use a weak variable which does not increment the reference count.

  • Xcode has a built in tool called Memory Graph Debugger that helps you locate memory leaks


  • When an object’s reference count reaches 0, it will get deallocated

Strong vs. weak

  • A weak variable means it does not increase the reference count where a strong variable does. 


Access control types

  • Private, Fileprivate, Open, Public, Internal


  • MVVM architecture offers two-way data binding between view and view-model. The view-model makes use of the observer pattern to make changes in the view-model. And some advantages are easier to do unit testing and less complex. Uses more memory due to its data binding. 


  • Disadvantages: large VCs, overly complex for single view apps

View lifecycle methods

  • viewDidLoad, viewWillAppear, viewDidAppear, viewWillDisappear, viewDidDisappear


  • The interface that one program used to interact with another.


Programmatic constraints


  • Reusability: Re-use code where similar layout is called for throughout the app.

  • Ease of control: If you want to change something(like a font color or size) on a repeated element, you can change one line of code instead of manually adjusting 10 different labels in interface builder.

  • Eliminate storyboard mess: The larger an app gets, the more confusing and harder it is to follow the flow of the storyboards.

  • Collaboration: Storyboards are just XML files. When multiple people are editing storyboards, it causes many merge conflicts that are a pain to resolve.


  • No visual representation of different views.

  • View controllers get larger from added code.

What is sync versus async?

  • Grand Central Dispatch is something that Apple created to help developers write multithreaded code without having to manually manage threads. So there are different kinds of queues that are available but what happens in a lot of apps is a networking call will be performed on a background queue to fetch data while the app can still run or for instance a user can still scroll on the TBV while data is being loaded to the cells. And when the data is retrieved it must be dispatched to the main queue to show up to the user. 

  • Synchronous code blocks the current queue until a task is complete.

Other questions 

Convenience initializer

  • Used to give properties default parameters and must call the designated initializer. For instance creating a custom button, to give you the choice of how to initialize it.

Designated initializer

  • A primary initializer for a class that assigns all properties and one must be called by all subclasses

What is a closure? Where have you used them?

  • Self-contained blocks of functionality that can be passed around and used in your code. Used with completion handlers such as one found in an alert.

Explain the Delegate pattern. Explain the Notification Pattern. What are the benefits of one versus another?

  • Delegate pattern: One to one communication pattern

What is a higher order function?

  • A function that either takes another function in as an argument or returns a function

Types of optionals

  • Nil coalescing, Optional chaining, Optional binding(if let), Guard let, Implicit unwrapping, Force unwrapping, Optional casting

UITableViewDataSource methods

  • Number of rows in section, cell for row at

UITableViewDelegate methods – name some

  • DidSelectRowAt, editingStyleForRowAt

What is a xib?

  • XML interface builder. Allows you design a designated chunk that can be added to a view controller

Computed property

  • A computer property is a property that gets computer when initialized.

Add or Answer questions here


What is the difference between a raw value and an associated value? 


(All definitions from:


  • Array: an ordered list of values

  • @objc: An attribute used to mark methods and properties that must be accessible to Objective-C code. Swift does not make its code accessible to Objective-C by default to avoid making the code larger than it needs to be.

  • Block: Can mean any chunk of code that starts with { and ends with } ("a code block"), but "block" is also the Objective-C name for closures.

  • Boolean: A data type that stores either true or false.

  • Class: A custom data type that can have one or more properties and one or more methods. Unlike structs, classes are reference types.

  • Class inheritance: The ability for one class to build on another, inheriting all its methods and properties. Some languages allow one class to inherit from multiple parents, but Swift does not.

  • Codable: A protocol that allows easy conversion between a struct or a class and JSON or XML.

  • Compound assignment operator: An operator that modifies a value and assigns it back to the original variable at the same time. For example, score += 1 adds 1 to the current value of score.

  • Condition: Any check that evaluates to true or false using an if statement. You can provide code to run when your condition is true, as well as an else

  • Default case: A special case for switch blocks that will match all other values.

  • Dictionary: A high-performance, unordered collection of values stored using a key for fast access.

  • Expression: Some code that evaluates to a value. For example, 12 * 12 evaluates to 144.

  • Extension: A set of additional methods and computed properties that are added to a concrete type, such as Int.

  • Failable initializer: An initializer that returns an optional value, because initialization might have failed for some reason. These are written as init?() or init!().

  • Force unwrap: The process of using the value inside an optional without checking it exists first. If the optional is empty – if it has no value – force unwrapping will crash your code.

  • Generics: The ability for one type or function to be used with a variety of data types. For example, Swift's arrays are generic, because you can make an array that stores integers, an array that stores strings, and so on.

  • inout parameter: A function parameter that, when changed inside the function, remains changed outside the function.

  • Library: A collection of code that you are using. Libraries differ from frameworks in that libraries are just collections of classes, structs, enums, and so on, for you to use however you want.

  • Operand: The values that work alongside an operator. For example, in 2 + 3 the 2 and 3 are operands.

  • Operator: Any symbol that acts as a function on values to its left and/or right. For example, + is an operator that adds two values together.

  • Predicate is a bool that asks for what you want back. Frank: Basically a filter.  

  • Range: Ranges span the distance between two values, up to and sometimes including the final value. This is mostly used with numbers: 1..<4 includes the numbers 1, 2, and 3, whereas the range 1…4 includes the numbers 1, 2, 3, and 4. Ranges can also be made from other data types, such as dates.

  • Scope: A region of code where variables and constants are valid. Each time you use an opening brace you start a new scope: all previous variables and constants remain valid in that scope, but any that are declared inside that scope are only valid until the scope ends with a closing brace.

  • Switch case: A system of evaluating multiple conditions in one block of code. For example, you might use switch age to evaluate the age variable, then have cases for 0 to 10, 10 to 20, 20 to 30, and so on. Switch blocks must be exhaustive in Swift, which means they must have cases to cover all possible values.


  • Associated value: A value that has been added to an enum case to provide some extra meaning. For example, you might have an enum case saying the weather is windy, then add an associated value saying how windy.

  • Catch: A keyword that starts a block of code to handle errors. You can specify what kind of errors should be caught, and use a generic "catch all" block to catch everything else. Paired with do.

  • Collection: A Swift protocol that is used by sequence types you can traverse multiple times without destroying them or affecting the collection, such as arrays and dictionaries.

  • Comparable: A common Swift protocol that says conforming types can be placed into an order using <.

  • Deinitializer: A special method that is called when an instance of a class is being destroyed. These may not accept parameters, and do not exist on structs.

  • Equatable: A common Swift protocol that says conforming types can be compared for equality using ==.

  • Function: A named section of your code that performs a specific, reusable task. You might pass in parameters to the function to customize how it runs, and it might return one or more values that are the result of its work.

  • Initializer: A special method that gets run to create an instance of a struct or class. You can have many initializers, and in the case of classes may call parent initializers inside your own initializer.

  • Keyword: Any word that has specific meaning as a Swift construct, such as class, continue, and try.

  • Lazy: A keyword that marks a property as being created only when it is first accessed. This is a performance optimization, because it means if the property is never accessed the work required to calculate its value is never done.

  • Nested type: A class or a struct that is defined inside another class or struct.

  • Memberwise initializer: An initialer for structs that is automatically generated by the Swift compiler, requiring that all properties must have a value. If you implement your own initializer inside the struct the memberwise initializer will no longer be generated by Swift.

  • Override method: A class's method that has the same name, parameters, and return type as a method on the class's parent class. The override keyword tells the Swift compiler you understand that you are changing the behavior.

  • Protocol: A list of criteria that a type must conform to, such as property names and methods. Protocols allow us to treat many objects the same way, because they implement all the behavior required to make the protocol work.

  • Protocol extension: A set of additional methods and computed properties that are added to a protocol, such as Equatable.

  • Protocol inheritance: The ability for one protocol to inherit requirements from another protocol. For example, the Comparableprotocol inherits from Equatable.

  • Polymorphism: The ability for an object to appear as and be used as multiple different types. For example, a Labrador class instance could also be used as a Dog and Mammal if you had defined those as parent classes.

  • Reference type: Any type that stores its data indirectly in memory, with the variable or constant really just being a pointer (or reference) to that piece of memory. If you point a second variable to a reference type, it will point at the same data in memory as the original reference, so the data is shared.

  • Repeat loop: A loop that will continue executing as long as its condition is true. If its condition starts false, it will still execute at least once.

  • String: A collection of letters, such as "Hello".

  • Subscript: Special methods that are used with collections, and provide easy access to read and write values in the collection. For example, someArray[3] is a subscript, as is someDictionary["name"].

  • Static method: A method that is shared across all instances of a struct or class, rather than unique to each instance. Because this is not run on a specific instance of a struct or class, it cannot access any properties that are not also marked static.

  • Statement: Some code that performs an action, such as print(age).

  • Throwing function: A function that has the ability to throw errors. These must be marked using the throws keyword in Swift, and called using try.

  • Tuple: A fixed-size collection of values of any type, like an anonymous struct. 

  • Typecasting: The ability to treat an object of one type as an object of a different type. This is needed when you know more information about the Swift compiler, such as when you instantiate a view controller from a storyboard.

  • try catch: The ability to run throwing functions and catch any errors that occur. You must start using a do block, then call any throwing methods inside that using try, and finally add one or more catch blocks to catch any errors. Writing a catch block to catch all errors is sometimes called a Pokémon catch, because "you gotta catch 'em all."

  • Variadic function: A function that takes one or more values of a specific type, separated by commas. The print() function is variadic, because you can write print(1) to print a single value, or print(1, 2, 3, 4, 5, 6, 7, 8) to print many.

  • Value type: Any type that stores its data directly in memory. If you point a second variable to a value type it will always copy the data in its entirety, rather than allowing it to be shared.


  • @autoclosure: An attribute attached to function parameters that are closures, which asks Swift to silently wrap any code using it in a closure rather than requiring users to do it by hand. This is used rarely, but it's important in the assert() function.

  • @available: An attribute attached to types or functions that mark them as being available or unavailable to specific versions of Swift or operating systems.

  • @discardableResult: An attribute attached to methods that return a value, marking the return value as safe to ignore if the caller wants to. When this is not used, Swift will show a warning if you don't do something with the function's return value.

  • @dynamicCallable: An attribute attached to types to mark them as being directly callable, primarily so that Swift can interact more easily with dynamic languages such as Python.

  • @dynamicMemberLookup: An attribute attached to types to mark them as being able to handle undefined properties using special methods, primarily so that Swift can interact more easily with dynamic languages such as Python.

  • @escaping: An attribute attached to function parameters that are closures, which tells Swift the closure will be used after the function has returned. This will in turn cause Swift to store the closure safely so that it doesn't get destroyed prematurely.

  • @objcMembers: An attribute used to mark classes where all properties and methods must be accessible to Objective-C code. Swift does not make its code accessible to Objective-C by default to avoid making the code larger than it needs to be.

  • @unknown: An attribute attached to the default case of switch blocks that allows code to handle enum cases that may be added at some point in the future, without breaking source compatibility.

  • Access control: A set of keywords that control how properties may be accessed by other code. open means the property can be accessed and overridden from anywhere, public means the property may be accessed from anywhere but overridden only within the module it came from, internal means the property may be accessed from anywhere inside the same module, fileprivate means the property may be accessed from anywhere inside the same file, and private means the property may be accessed from anywhere inside the same type.

  • ABI: The description of how the Swift compiler produces binaries: how data structures are laid out in memory and accessed, how functions are called, and so on.

  • Associated type: A missing type in a protocol that must be specified by whatever type is conforming to the protocol. Associated types allow us to have flexibility when adding conformances: we can say that to conform to our protocol you must have an array of items, but we don't care what the data type of those items is. Associated types are written as one word in Swift: associatedtype.

  • Break: A keyword that exit the current loop. If used with a labeled statement, e.g. break myLoop, it will break out of the specified block.

  • Capturing values: The name for the process of closures keeping a reference to values that are used inside the closure but were created outside. This is different from copying: the closure refers to the original values, not its own copies, so if the original values change then the closure's values change too.

  • CaseIterable: A Swift protocol that can be applied to enums. If the enum has cases with no associated values, the compiler will generate an allCases array that lets you loop over the cases in the enum.

  • CGFloat: A floating-point number that may be equivalent to a Double or Float depending on the platform.

  • Closure: An anonymous function that automatically keeps a reference to any values it uses that were declared outside the function.

  • Compiler directive: One of several special pieces of code written using a #, that act as instructions to the compiler. For example, compiler directives can check whether we're targeting the simulator or not, and compile one of two code variants.

  • Computed property: Any property that does not have a simple storage area for its value, and instead is calculated each time the property is accessed by running some code.

  • Conditional conformance: The ability to say that a type conforms to a protocol only if specific conditions are met. For example, Swift's arrays conform to Equatable only if their element also conforms to Equatable.

  • Continue: A keyword that exits the current iteration of a loop, causing the loop to start its next iteration immediately. If used with a labeled statement, e.g. continue myLoop, it will continue the specified block.

  • Data: A type that holds any kind of binary data.

  • Defer: A keyword that allows us to schedule work for when the current scope is exited.

  • Double: A high-precision floating-point number, such as 3.1, or 3.141592654.

  • Enum: A set of named values that are easier to remember and safer than just using strings or integers. For example, you might create an enum of directions, using north, south, east, and west – this is much nicer than using 0, 1, 2, and 3, for example. Short for "enumeration". Pronounced as "ee-numb", but "ee-noom" is an accepted variation.

  • Error: A Swift protocol that our own enums can conform to, which we can then use to throw errors from functions.

  • Fallthrough: A keyword used in switch blocks to mean "carry on executing the case immediately following this one."

  • Final class: A class that may not be inherited from by anything else.

  • Float: A low-precision floating-point number, such as 3.1, or 3.141592654.

  • For loop: A loop that counts through all values in a sequence, such as an array or a range.

  • Framework: A collection of code that you are using. Frameworks differ from libraries in that frameworks usually take over control of their operation, and call back to you when they need information.

  • Functional programming: A programming approach that favors sending and receiving immutable data to and from functions, avoiding side effects, and composing functions together.

  • Hashable: A common Swift protocol that says conforming types can be represented using hash values.

  • Higher-order function: A function that accepts another function as a parameter, or sends back a function as its return value.

  • Implicitly unwrapped optional: A special Swift optional that may or may not contain a value, but does not need to be checked before use. If you attempt to use an implicitly unwrapped optional that has no value, your app will crash.

  • Indirect enum: An enum that is compiled specially so that it can reference itself in its associated values. For example, if you had a linked list enum that needed to reference another linked list item as an associated value, this would need to be indirect.

  • Infinite loop: A loop that never ends until you say so. This is most commonly done using a boolean variable set to true – you can set it to false as soon as you want the loop to end.

  • Keypath: A way of referring to properties without actually reading them.

  • Labeled statement: A name attached to a specific block of code, such as a loop or a condition, allowing you to break out of it specifically even if you are inside other blocks. For example, if you are inside a loop that's inside a loop that's inside a third loop, you could exit the outermost loop.

  • Multi-line strings: A string that spans multiple lines. Multi-line strings in Swift must start and end with three double quotes on their own line.

  • Mutating method: A method on a struct that will change one of the properties of the struct. This must be used because only variable structs can have mutating methods called on them. Mutating methods are not required for classes, where every method can be mutating without the keyword.

  • Property observer: Code added to a property using willSet and didSet, that gets called whenever a property is being changed.

  • Property wrapper: An attribute placed around a property that gives it custom abilities. For example, you could write a @UserDefaults property wrapper to make loading and saving data to user defaults easier.

  • Protocol-oriented programming: An approach to programming that favors code re-use through protocol extensions, providing the benefits of multiple inheritance without some of the complexity. Specifically, protocol-oriented programming (POP) cannot add stored properties to a type, so there is less cruft.

  • Raw strings: The ability to specify custom string delimiters for situations when you want to use backslashes and quote marks without them having their regular meaning.

  • Raw value: A simple underlying data type that enum values can be mapped to for the purpose of loading and saving. For example, you might say that the planets Mercury, Venus, and Earth have the integer raw values 1, 2, and 3.

  • Rethrowing functions: A function that uses the rethrows keyword so that it throws errors only if the closure it accepts throws errors.

  • Runtime: When your code is running, as opposed to compile time, which is when the code is being built.

  • Selector: A way of referring to functions without actually calling them, usually for the purpose of calling them later on.

  • Serialization: The process of converting objects into text or binary, and vice versa. For example, converting an array of users into JSON, or converting JSON into an array of users.

  • Set: A high-performance, unordered collection of values of any type that conforms to the Hashable protocol.

  • Shorthand parameter name: Special parameter names made available inside closures, written as a dollar sign the numbers starting from 0. For example, if a closure accepts a name string and an age integer, you could refer to the string as $0 and the age as $1. Note: you may not mix and match shorthand syntax with regular syntax.

  • StaticString: A specialized form of Swift's String that must be hand-typed – you must literally type the string directly into your code rather than using string interpolation.

  • Synthesize: The name for when the Swift compiler generates code on your behalf. For example, if you say that a custom struct conforms to Equatable, and all its properties already conform to Equatable, then Swift can synthesize a == function for it.

  • Trailing closure syntax: The ability for functions that accept a closure as their final parameter to have that closure specified after the function's parentheses, which usually helps make the function call easier to read.

  • Type alias: A type alias is the ability to specify what type should fill an associated type. This is usually not needed, because Swift can figure out the type alias just by looking at properties used with the associated type. Type aliases are written as one word in Swift: typealias.

Leave a Reply

Your email address will not be published. Required fields are marked *