iOS interview questions and answers 👇

  1. iOS Interview Questions


iOS Interview Questions

1.

Explain the Adapter and Memento Pattern?

Adapter – It lets the classes with incompatible interfaces to work together and it wraps itself around the object to expose a standard interface to interact with that object.

Memento – This pattern in iOS is used as a part of state restoration. That is this externalized state can be restored without violating any encapsulation. This pattern is especially used for the archiving in Apple.

2.

Can you explain completion handler?

When our application is making an API call and we are supposed to update the UI to show the data from the API call, then Completion Handler becomes handy and is super convenient.

3.

What do you do when you realize that your App is prone to crashing?

Firstly, determine the iOS version or model of the device. Collect enough information to reproduce the issue. If possible, acquire device logs. Acquire tooling or create a unit test and begin debugging once you get the idea of the nature of the issue.

4.

Explain Core Data.

Core data is one of the most powerful frameworks provided by Apple for macOS and iOS apps. Core data is used for handling the model layer object in our applications. We can treat Core Data as a framework to filter, modify, save, track the data within the iOS apps. Core Data is not a relational database.

Using core data, we can easily map the objects in our app to the table records in the database without knowing any SQL. Core data is the M in MVC structure.

5.

Explain the Grand Central Dispatch (GDC).

GCD (Grand Central Dispatch) is a low-level API for managing the concurrent operations. This concept is used to help in improving application performance. This process is used to manage multiple tasks at the same time. Grand Central Dispatch (GCD) is the most useful API for multitasking with Async and Sync programming in iOS.

  • Dispatch Queue: The Dispatch Queue manages the task in FIFO(First In First Out) order. Dispatch queues are thread-safe as we can access them from multiple threads simultaneously.
  • Concurrent: This process has started multiple tasks at the same time but is not sure of the termination at the same time. It can be finished in any order. They execute one or more tasks at the same time concurrently. The task is completed according to the complexity, and not by the order in the queue.
  • Serial: Only one task will execute at a time. It can be used to synchronize access to a specific resource.
  • Sync: A synchronous function has return control to the caller after the task is complete.
  • Async: An asynchronous function returns immediately, by ordering the task to start but will not wait for it to complete.
6.

Explain MVC structure.

MVC stands for the model view controller. MVC is a powerful software architecture pattern for using developing apps.

MVC builds on top of the Object-Oriented Programming concepts. It structures the flow of data and interaction in our app. Model-View-Controller is an important fundamental concept to be understood in iOS development. Many iOS frameworks, like UIKit, Cocoa Touch, use the MVC pattern for messaging and structured data flow.

Model-View-Controller is used to pass the data from one part of our app to another.

Its a design pattern used to assign objects in an application in any one of the three roles:

  • Model: Model is a wrapper of data. Model is a representation of our app data and it holds the information to a specific user like birthdate, username, etc. The model manages the application state. This also includes writing and reading data. The Model encapsulates an individual set of data and applies some logic to manipulate that data.
  • View: View is a representation of a UI (User Interface). A View is an object that the visible to the user and it interacts with a user interface (UI).
  • Controller: Controller is an intermediary between the View and the Model. The controller controls all the logic that goes between the Model and the View. Its inter-communicates messages between the Model and the View, and vice versa.
7.

How is memory management handled in iOS?

Swift uses Automatic Reference Counting (ARC). This is conceptually the same thing in Swift as it is in Objective-C. ARC keeps track of strong references to instances of classes and increases or decreases their reference count accordingly when you assign or unassign instances of classes (reference types) to constants, properties, and variables. It deallocates memory used by objects whose reference count dropped to zero. ARC does not increase or decrease the reference count of value types because, when assigned, these are copied. By default, if you don’t specify otherwise, all the references will be strong references.

8.

What do you know about singletons? Where would you use one and where would you not?

Singleton is a class that returns only one and the same instance no matter how many times you request it.

Singletons are sometimes considered to be an anti-pattern. There are multiple disadvantages to using singletons. The main ones are global state, object life-cycle, and dependency injection. When you have only one instance of something, it’s very tempting to reference and use it everywhere directly instead of injecting it into your objects. That leads to unnecessary coupling of concrete implementation in your code instead of working with an interface abstraction.

Another malicious side effect of “convenient” singletons is the global state. Often singletons enable global state sharing and play the role of a “public bag” that every object uses to store state. That leads to unpredictable results and bugs or crashes when this uncontrolled state gets overridden or removed by someone.

9.

What’s different between delegate and KVO?

Both are ways to have relationships between objects. Delegation is a one-to-one relationship where one object implements a delegate protocol; another sends messages to it, using methods defined by the protocol. KVO is a many-to-many relationship where one object broadcasts a message, and one or more other objects listen to it and react. KVO does not rely on protocols. KVO is the first step and the fundamental block of reactive programming (RxSwift, ReactiveCocoa, etc.)

10.

What are design patterns besides common Cocoa patterns that you know?

Besides commonly used MVC, Singleton, Delegate, and Observer patterns, there are many others that are perfectly applicable in iOS applications: Factory Method, Adapter,Decorator, Command, and Template.

Factory Method is used to replace class constructors, to abstract and hide objects initialization so that the type can be determined at runtime, and to hide and contain switch/if statements that determine the type of object to be instantiated.

Adapter is a design pattern that helps you, as the name suggests, adapt the interface of one object to the interface of another. This pattern is often used when you try to adapt third-party code that you can’t change to your code, or when you need to use something that has an inconvenient or incompatible API.

Decorator is a wrapper around another class that enhances its capabilities. It wraps around something that you want to decorate, implements its interface, and delegates messages sent to it to the underlying object or enhances them or provides its own implementation.

Command is a design pattern where you’d implement an object that represents an operation that you would like to execute. That operation can have its own state and logic to perform the task it does. The main advantages of this design pattern are that you can hide internal implementation of the operation from the users, you can add undo/redo capabilities to it, and you can execute operations at a later point in time (or not at all) instead of right away where the operation was created.

Template is a design pattern where the main concept is to have a base class that outlines the algorithm of what needs to be done. The base class has several abstract methods that are required to be implemented by its concrete subclasses. These methods are called hook methods. Users of the Template Method classes only interact using the base class that implements the algorithm steps; concrete implementations of those steps are supplied by subclasses.

11.

What options do you have for implementing storage and persistence on iOS?

In-memory arrays, dictionaries, sets, and other data structures NSUserDefaults/Keychain File/disk storage Core Data, Realm SQLite In-memory arrays, dictionaries, sets, and other data structures are perfectly fine for storing data intermediately or if it doesn’t have to be persisted.

NSUserDefaults/Keychain are simple key-value stores. One is insecure and the other is secure, respectively.

File/disk storage is a way of writing data (serialized or not) to/from a disk using NSFileManager.

Core Data and Realm are frameworks that simplify work with databases.

SQLite is a relational database and is good when you need to implement complex querying mechanics and Core Data or Realm won’t cut it.

12.

What options are available for networking and HTTP on iOS?

In iOS there are several options to implement HTTP networking. You can go with good old NSURLSession, but unless you abstract it out well enough, it can be daunting to work with. Another option would be to use a wrapper library around it. The most popular solution on iOS is Alamofire.

In general, if you have a small team you likely want to rely on open sourced solutions such as Alamofire that abstract a lot of boilerplate code out for you; but if you’re in a big team and can spare resources you’d want have more control over how data is passed to/from your server and implement it yourself using NSURLSession.

Senior developers should keep in mind that building the networking layer in iOS applications means not only dealing with HTTP requests but implementing the whole set of tasks your code does related to that: HTTP networking, data serialization, and data mapping.

13.

How and when to serialize and map data on iOS?

There are two most common scenarios where you’d need to serialize and map data in iOS applications: receiving or sending data in the networking layer (such as JSON or XML or something else), and persisting or retrieving models in the storage layer (NSData, NSManagedObject).

Every time you receive JSON or XML or any other response type of response from a backend API, you most likely get it in a JSON or binary or other “inconvenient” format. The first thing you need to do to work with the data you’ve received is to serialize it in something your app understands. At the most simplest and basic level that would be a dictionary or an array of objects containing other dictionaries, arrays, and primitives from that response. NSJSONSerialization takes care of that. The next step is to map that data into domain models of your application. Those would be the model objects or structs for the rest of your application to use. You can either do it manually or use Codable protocol provided by Apple or use a library such as Mantle or SwiftyJSON. The flow of data and serialization/mapping is: binary data -> json -> NSDictionary/NSArray -> your domain model objects.

Similarly, in the storage layer, you will need to serialize and map your data to and from your custom domain model objects to the format your storage understands. The “mapping” chain for reading data: db -> raw data format -> custom domain models; and for writing: custom domain models -> raw data format -> db. You’d use the NSManagedObject or NSCoding or Codable protocol here to achieve that.

14.

What are the options for laying out UI on iOS?

Go-to options for laying out views on the screen are good old CGRect Frames and AutoLayout. Frames, along with auto-resizing masks, were used in the past before iOS 6 and are not a preferred option today. Frames are too error-prone and difficult to use because it’s hard to calculate precise coordinates and view sizes for various devices.

Since iOS 6 we have AutoLayout, which is the go-to solution these days and which Apple prefers. AutoLayout is a technology that helps you define relationships between views, called constraints, in a declarative way, letting the framework calculate precise frames and positions of UI elements instead.

With iOS 13, Apple introduced a new approach for laying out views - SwiftUI, which is a declarative approach that supports FRP (functional-reactive programming) data bindings with Combine. FRP and declarative UI are not new concepts, but SwiftUI and Combine are new frameworks from Apple that support it. The declarative nature of SwiftUI allows you to declare your UI elements very concisely and then later through data bindings declare what parts of the UI, such as text labels for example, to update upon what data model changes. In effect, it allows you to do what was already possible with RxSwift before, but now with Apple frameworks.

There are other options for laying out views, such as ASDK (Texture), ComponentKit, and LayoutKit, and some of them are more or less inspired by React and others solve layout Asynchronicity differently. These alternatives are good in certain scenarios when, for example, you need to build highly dynamic and fast table views and collection views. AutoLayout is not always perfect for that and knowing there are other options is always good.

NOTE: we’ll see how SwiftUI proves itself solving complex UI problems and complex async UI layout problems in the future, it’s a very new technology as of the time of this writing.

15.

How to optimize scrolling performance of dynamically sized table or collection views?

Scrolling performance is a big issue with UITableViews and quite often can be very hard to get right. The main difficulty is cell height calculation. When the user scrolls, every next cell needs to calculate its content and then height before it can be displayed. If you do manual Frame view layouts then it is more performant but the challenge is to get the height and size calculations just right. If you use AutoLayout then the challenge is to set all the constraints right. But even AutoLayout itself could take some time to compute cell heights, and your scrolling performance will suffer.

Potential solutions for scrolling performance issues could be:

calculate cell height yourself keep a prototype cell you fill with content and use it to calculate cell height

Alternatively, you could take a completely radical approach, which is to use different technology like ASDK (Texture). ASDK (Texture) is made specifically for list views with dynamic content size and is optimized to calculate cell heights in a background thread, which makes it super performant.

16.

How would you execute asynchronous tasks on iOS?

These days on iOS your go-to solutions for async tasks are NSOperations and GCD blocks. Grand Central Dispatch is a technology that was made to work with multiple background queues that in turn figure out which background thread handles the work. The main thing is that this is abstracted out from you so that you don’t have to worry about it. NSOperation is an OOP abstraction on top of GCD that allows you to do more sophisticated async operations, but everything you could achieve with NSOperations you could do with GCD. Many Cocoa frameworks use GCD and/or NSOperations under the hood (NSURLSession for example).

There are alternative ways of handling async work using third-party libraries’ help. The most notable are Promises (PromiseKit), RxSwift, and ReactiveCocoa. RxSwift and ReactiveCocoa are especially good at modeling the asynchronous nature of time and work that needs to be done in the background and coordinated among threads.

17.

How do you manage dependencies?

A few years back, we didn’t have any dependency managers on iOS and had to copy-paste and drag-and-drop third-party code into our projects or to use Git sub-modules. Those approaches proved to be unmanageable as our codebase and dependencies grew.

These days we have other dependency managers to choose from: CocoaPods, Carthage, and Swift Package Manager.

So far the most dominant and robust one is CocoaPods. I was built in the spirit of the Ruby Bundler gem and is a Ruby gem itself. The way it works is you install the gem, create Podfile in the root directory of your project, declare the pods (libraries) you want to use, and run pod install. That’s it.

With Carthage, you create a dependencies declaration file called Cartfile but unlike Cocoapods you’d need to do Xcode project setup to make it work.

Swift Package Manager is the future of dependency management for any Swift project but it only supports libraries and frameworks and cannot be used to generate iOS targets, although iOS targets can depend on modules built by SPM.

18.

How do you debug and profile code on iOS?

There’s always NSLogging and printing in iOS apps. There are breakpoints you can set using Xcode. For performance of individual pieces of code, you could use XCTest’s measureBlock.

You can do more advanced debugging and profiling using Instruments. Instruments is a profiling tool that helps you profile your app and find memory leaks and performance issues at runtime.

19.

Do you have TDD experience? How do you unit and UI test on iOS?

TDD is a technique and a discipline where you write failing tests first before you write production code that makes them pass. The tests drive implementation and design of your production code, helping you write only the code necessary to pass the tests implementation, no more, no less. The discipline could be daunting at first and you don’t see payoff of that approach immediately, but if you stick to it, it helps you move faster in the long run. It is especially effective at helping you with refactoring and code changes because at any given time you have the safety net of your tests to tell you if something broke or if everything is still working fine as you change things.

Recently Apple made improvements to XCTest frameworks to make testing easier for us. They also made a lot of improvements with UI testing in Xcode (XCUITest), so now we have a nice programmatic interface to interact with our apps and query things we see on the screen. Alternatively you could go with frameworks like KIF, iOSSnapshotTestCase, EarlGrey.

In regards to unit testing, there are several options as well, but the two most popular ones are XCTest and Quick and Nimble.

XCTest is a xUnit like testing framework built by Apple. This is what they recommend to use, and it has the best integration with Xcode.

Quick is a RSpec-like BDD framework that helps you describe your specs/tests in terms of behavior rather than “tests.” Fans of RSpec like it a lot.

Nimble is a matcher library that can be used with XCTest or Quick to assert expectations in your tests/specs.

20.

What different between mocks, stubs, and fakes?

There are various ways different people call and categorize test objects but most commonly test objects can be categorized in the following way: fakes, stubs, and mocks.

Fakes is the general umbrella term for any kind of mock, fake, stub, double, etc. On their own, they typically have no implementation and only fulfill the interface API requirements of the types they are substituting.

Stubs are fakes that do some meaningful work that’s necessary for the objects involved in a test to operate, but not used for anything more than that. They can’t be used in place of real production objects but can return stubbed values. They can’t be asserted on.

Mocks are fakes that can be asserted on. Mocks are used in place of other objects just like a fake, but they themselves record some data such as the number of method calls or variables passed for your test to assert on later.

21.

What is FRP (Functional Reactive Programming) and its place in iOS platform?

Functional Reactive Programming (FRP) is a declarative programming paradigm that combines functional programming and reactive (async dataflow programming) paradigms. It is a declarative style of programming where you declare what your code does rather than state how it does it. The reactive component of FRP allows us to introduce and describe the concept of time, which is hard to work with in pure functional programming. FRP helps us deal with user input and the asynchronous nature of iOS applications in general; user input happens at some point in time, networking will finish some time in the future, etc.

FP and FRP rely on higher-order functions such as map, reduce, and filter that take functions as arguments and return other functions, which makes them highly composable.

Swift doesn’t have native support for FRP, but there are two excellent libraries that implement functional reactive programming concepts and make them easily available to us: ReactiveCocoa and RxSwift.

In iOS 13, Apple also announced a new FRP framework built into iOS called Combine. Combine is effectively an FRP framework implementation similar to RxSwift. The two advantages it has: it’s integrated with SwiftUI allowing it to bind UI elements to data changes, and it’s built-in and supported by Apple. Disadvanges are: it’s less mature than RxSwift and Apple will be slow to make changes and additions to it.

22.

What iOS architectures do you know that scale?

MVC, MVVM, MVP, and similar design patterns are great and each is an improvement on the other, but they still do not scale well for teams larger than 10 or 20 people. If you’re beyond that team size, you need to use a more generic and scalable architectural approach. There is such a conceptual approach, called Clean Architecture.

Clean Architecture is a conceptual application architecture for scale and can be simply described as “an onion layered architecture”. The main idea is to keep dependencies pointing inward towards your domain logic and domain models and keeping everything else pluggable and optional (the way you store data, render ui, receive or send networking requests, etc.). This architecture scales particularly well for large teams of 100+ developers.

There are two concrete implementations of Clean Architecture on iOS: VIPER and RIBs.

VIPER stands for View, Interactor, Presenter, Entity, and Router. Those are the building blocks of that architecture. In this architecture, everything starts with a router and ends with a view. Each VIPER stack (meaning a set of a View, Interactor, Presenter, Entity, and Router) is one screen or one logical UI part of your application. To navigate and use a VIPER stack, you'd instantiate its router and then ask it to create its view controller. The router creates a view controller, a corresponding presenter that formats data for the view and receives user input for the view, an interactor that holds business logic and communicates with presenter, and entities necessary for interactor to work. Then the VC owns presenter, presenter owns interactor, and interactor owns entities and the router. The resulting view controller is used in your view hierarchy and inserted, pushed, or presented as necessary. This architecture allows for strong encapsulation of logic and scalability for team size since every part of your app is now a VIPER stack.

RIBs stands for Router, Interactor, Builder. RIBs is another implementation of Clean Architecture that was an improvement on VIPER. In RIBs architecture, the main building block is a RIB, a set of one router, one interactor, and one builder with optional view and presenter. RIBs without a view are called headless RIBs. Just like in VIPER architecture, you route from one RIB to another using router, and that structures the entire runtime of your app in as a tree structure with parent and children RIBs. Since the view is optional, unlike with VIPER, your application tree structure might or might not mimic your view hierarchy.

Builder is responsible for fetching or creating dependencies for the interactor, router, and the view/presenter assembling and initializing them.

Router is responsible for navigating to specific children RIBs.

Interactor is responsible for all the business logic and initiating routing using router.

Presenter and the view are typically combined in a view controller where presenter is responsible for massaging and formatting data for display in the view.

View is responsible for display data on the screen and collecting user input.

23.

How would you create a HTTP request in iOS?

One way of creating a HTTP request in iOS is by using URLRequest with URLComponents.

var components = URLComponents()
components.scheme = "https"
components.host = "api.github.com"
components.path = "/search/repositories"
components.queryItems = [
    URLQueryItem(name: "q", value: "swift"),
    URLQueryItem(name: "sort", value: "stars")
]

let url = components.url

With URLComponents you can easily define the URL components and then create a URLRequest out of it.

24.

How would you send and receive HTTP requests in iOS?

One possibility for sending and receiving HTTP requests is by using URLSession. With URLSessionConfiguration, you can configure caching behaviour, timeout values and HTTP headers.

A session works with tasks. After creating a session you can use URLSessionDataTask to send a request and to get the response:

let urlSession = URLSession(configuration: .default)
let task = urlSession.dataTask(with: url) { data, response, error in
    // Handle response.
}
task.resume()

You can also use URLSessionDownloadTask to download and URLSessionUploadTask to upload files. You can suspend, resume and cancel tasks.

25.

In iOS, a networking feature called App Transport Security (ATS) requires that all HTTP connections use HTTPS. Why?

HTTPS (Hypertext Transfer Protocol Secure) is an extension of HTTP. It is used for secure computer network communication. In HTTPS, the communication protocol is encrypted using TLS (Transport Layer Security).

The goal of HTTPS is to protect the privacy and integrity of the exchanged data against eaves-droppers and man-in-the-middle attacks. It is achieved through bidirectional encryption of communications between a client and a server.

So through ATS, Apple is trying to ensure privacy and data integrity for all apps. There is a way to circumvent these protections by setting NSAllowsArbitraryLoads to true in the app’s Information Property List file. But Apple will reject apps who use this flag without a specific reason.

26.

How would you convert a JSON response into native Swift types?

Swift’s Codable protocol makes it easy to convert JSON to native Swift structs and classes. The first step is to define a Swift type that has the same keys and value types as the JSON and conforms to Codable. For example:

struct Doggy: Codable {
    let name: String
    let age: Int
}

Then we can use JSONDecoder to convert:

let decoder = JSONDecoder()
do {
    let doggies = try decoder.decode([Doggy].self, from: jsonData)
    print(people)
} catch {
    print(error.localizedDescription)
}
27.

Do you have experience with third-party iOS networking libraries? If so, which ones?

The interviewed person could name following libraries:

Alamofire - an abstraction layer over URLSession to make networking more simple and elegant Moya - an abstraction layer over Alamofire that creates a type-safe structure for network services and requests

28.

Explain main thread and it’s usages

In iOS, application main thread is a globally available serial queue. Main thread should be used for all views and interface elements must not be blocked by long running tasks. Developer should avoid functions using main thread to load data, images, etc.

29.

What is serial queue?

The serial queue can run tasks one at a time and it needs to wait for the started tasks to finish.

30.

What is concurrent queue?

The concurrent queue can run as many tasks as it can without waiting for the started tasks to finish.

31.

What is priority inversion?

Priority inversion is a critical condition in threading where a low priority thread blocks a high priority thread from executing and make the assigned priorities meaningless for the thread.

32.

What is concurrency and time slicing?

Concurrency is the structural way to run multiple tasks at the same time. Time slicing is used to provide concurrency in a single core device. In case of using time slicing in single core device – one thread will run on specific time and perform a context switch, then another thread will run. Multi-core devices can run multiple threads at the same time via parallelism.

33.

What is NSOperation?

NSOperation is built on top of GCD. While using NSOperation developer can add dependency among various operations and re-use, cancel and suspend operations. Of course the same thing can also be archived through GCD but it will add extra overhead.

34.

35.

36.

What is NSBlockOperation?

NSBlockOperation helps you to implement the NSOperation from one or more closures. NSBlockOperations can have multiple blocks, that can run concurrently.

37.

What is semaphore?

Semaphores gives us the ability to control access to a shared resource by multiple threads. A semaphore consist of a threads queue and a counter value. Counter value is used by the semaphore to decide if a thread should get access to a shared resource or not. The counter value changes when we call signal() or wait() functions.

38.

Do your need weak or unowned for UIView animation?

weak or unowned self is used to prevent retain cycles. After UIView animation runs, the memory is deallocated even if it is strongly referenced. Weak and unowned is not needed for animation code block. You don’t need to use [weak self] in static function UIView.animate() You need to use weak when retain cycle is possible and animations block is not retained by self. The external object reference captured by them will only be kept for certain amount of time, which means it’s definitive that it’s going to be executed at one point of time. After this, it will be released so there is no chance of reference cycle which leads to memory leak.

39.

When should you use frame/bounds?

Frame relates a view’s location in its parent view. It can be used when you are making outward changes for example changing its width or finding the distance between the view and the top/bottom/left/right of its parent view.

On the other hand you can use the bounds when you are making inward changes for example draw items or arrange subviews within the view. You can also use the bounds to get the size of the view if you do any transformation on the bounds.

40.

What is an unwind segue?

An unwind segue moves backward through one or more segues to return the user to a scene managed by an existing view controller.

41.

What is intrinsic content size?

All views have an intrinsic content size which refers to the amount of space the view needs for its content to appear in an ideal state. For example, the intrinsic content size of a UILabel will be the size of the text it contains using whatever font you have configured it to use.

42.

What’s the difference between a xib and a storyboard?

A xib defines a single View or View Controller screen, while a storyboard shows many view controllers and also shows the relationship between them.

43.

What is difference between layout margins and directional layout margins ?

Layout margins property of a UIView is of type UIEdgeInsets and defines the top, left, bottom and right insets that when applied to the view’s frame define the view’s margin.

Directional layout margins that are aware of right to left (RTL) languages. This follows the pattern used when creating constraints with layout anchors.

44.

What is Safe area ?

Safe area allows us to create constraints to keep our content from being hidden by iOS specific hardware bars.

45.

What is reuseIdentifier in UITableView/UICollectionView?

The reuseIdentifier indicates that cells for a UITableView (or UICollectionView) can be reused. UITableView maintains an internal cache of UITableViewCell with the appropriate identifier and allows them to be reused when dequeueForCellWithReuseIdentifier is called. As a result, this increases performance of UITableView since a new view does not have to be created for a cell.

46.

What is NSLayoutAnchor ?

NSLayoutAnchor is used to write auto layout easier in code.

47.

What is ARC ?

ARC/Automatic Reference Counting is a compile time feature for memory management in iOS. While using ARC, it only deallocate the memory for the objects when there are zero strong references to them.

48.

What is circular dependencies ?

When two or more modules depend on each other directly or indirectly to work properly create circular dependency. These kind of dependencies are also called mutually recursive.

49.

What is a retain cycles?

Retain Cycle is the situation when two objects keep a reference to each other and are retained, it creates a retain cycle since both objects try to retain each other, making it impossible to release. 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.