In this article, we’ve collected questions and assignments that are common in iOS developer interviews.
Optional
What is optional? What are some ways to deploy optional you know? What is an implicitly deployed 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. You can use it to protect yourself from trying to access a nil value.
Multithreading .
You can read about it in the article about GCD and Dispatch Queues.
The difference between frames and bounds
This is one of the favorite questions in iOS interviews. A bounds rectangle is referenced from its coordinate system and a frame is referenced from the container it is in (superview).
Weak Links
When should we use weak links? What’s the difference between weak and unowned?
Weak links do not increase the link count like unowned ones. The difference between unowned and weak links is that they are not optional. Weak is used when we know that a link can be nil. Unowned is when we know that the link will never be nil.
The life cycle of an application
- Not running: the application has not started or has been terminated by the system.
- Not active: the application is running, but is not currently responding to events (But can execute code). This state is usually short-lived and in-between.
- Active: The application is running and responding to events.
- In Background: The application is running in the background. Most applications do not stay in this state for very long before being suspended. However, an application that has requested additional time in the background 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 not executing code. The system puts applications in this state automatically, without prior notification. In this state, the application is still in memory, but cannot execute code. If a memory shortage occurs, the system may clear suspended applications without prior notification to free up more space for active suggestions.
ViewController lifecycle
- loadView: is used when a controller is created in code. loadView is called by the controller when its current view is nil.
- viewDidLoad: is called once per controller lifetime. The method is called when all views are loaded.
- viewDidLayoutSubviews: Called when any view is changed.
- viewDidAppear: Called when a view appears on the screen.
- viewDidDisappear: is called when a controller’s view is removed.
Access modifiers
- public and open – open allows you to inherit and overload classes and class members inside and outside a module. public – only inside module.
- internal – access within the module.
- fileprivate – access within a file.
- private – access within the entity where the object is defined.
Which works faster: an NSArray search or an NSSet search?
NSSet searches will be faster because sets, like dictionaries, use hashes.