It’s a New Year!
Perhaps you are looking for a new job, or are thinking about upgrading your developer self.
Why not use this quick list of Interview Questions and Answers?
Hand-picked and selected for 2021, these are the terms and questions that you need to know for your iOS dev role!
app ID / bundle ID App ID identifies one or more Apps from a development team. Bundle ID uniquely identifies each App. AppID is local, BundleID is on Apple’s side.
Access control open, public, internal, fileprivate and private.
App states Not running, inactive, active, background and suspended. Not running — not launched, inactive is foreground but not receiving events (transitioning states), active is normal, background is executing code, suspended is in the background not executing code.
automic and nonatomic synthesized properties automic thread safe and slow, nonatomic multiple threads.
Bound vs Frame A frame is in the superviews coordinate system. A bound is in the views own coordinate system.
Class or struct Class is pass by reference, struct by value. Apple recommend using structs as the default.
Cocoa and Cocoa Touch The former is for OSX, the latter for iOS.
Concurrency in iOS Delivered through threads, dispatch and operation queues. Concurrency is tasks running in overlapping time periods (time slicing) whereas parallelism is about performing work at the same time. Concurrency is in the same time space, parallelism at the same time.
Copy on write Swift only copies value types when they need to be changed, if not use the same instance of the value type.
Copy retain difference Similar to pass by reference and value. Retain increases the retain count, whereas copy clones the object.
Delegate pattern Is ubiquitous throughout the iOS APIs. Shifts responsibility from one class to another, creating a separation of responsibilities and concerns (avoid tight coupling). Gives a message to a single listener (the delegate).
Escaping closures: can outlive the function, through use of the @escape keyword.
Extension or category Categories and extensions allow you to functionality to an object without subclassing or changing the object. Extensions are not names (categories are). Categories can be used to add methods to pre existing classes (String, Float, etc.) whereas extensions allow us to add extra features to our custom class.
final prevents overrides.
Frameworks from UIKit to AFNetworking, RXSwift through Alamofire and Realm frameworks are incredibly important in the development of applications. CocoaPods is one dependency manager that helps you to us Frameworks in your project.
Grand Central Dispatch (GCD) abstracts threading through the concept of queues. Main queue, private queue are possible. Can choose concurrent queues and can dispatch using async or sync.
Any and AnyObject differences AnyObject is only for reference types (in particular classes), whereas Any can be used for anything.
loadView loadView() creates and instantiates the UIView object. Should not be called directly, is used to create views. Not used if using IB.
Method Swizzling Change the functionality of a method at runtime. (actually a selector is an example if this). Hard to maintain. Can be used to swap out viewWillAppear to track every view, while keeping the original around. Google Analytics / Firebase is an example of this.
Memory leak A portion of memory that is occupied forever and never used again. This takes space and causes problems in the App.
Control transfer statements Break, continue, fall through, return and throw.
Pass by value / Pass by reference structs, enums and tuples are value types, and each instance keeps a copy of its data. Classes are pass by reference, and instances share a single copy of data.
Pros of native over React Native Having one codebase is preferable over multiple codebases for different platforms, making it faster and cheaper and even opens the door for web development. However, RN does not support all APIs. Equally to link into native components you need to use native code, fragmenting the codebase taking away the single largest benefit of using React Native.
Protocol Lists required an optional methods that must be implemented from a class, struct or enum that adopts the protocol.
reuseIdentifier Indicates that a cell can be reused in a UITableView, the UITableView maintains an internal cache of UITableViewCells.
unowned similar to weak, but not optional.
viewDidLoad, viewDidAppear viewDidLoad is called when the viewcontroller is loaded, viewDidAppear where the viewcontroller is visible.
weak or strong A strong reference means that only when the owning object is destroyed, the descendent object will only then be destroyed. A weak reference means that it can be destroyed when no other object has a strong reference to it.
When guard let, when if let guard is for incorrect inputs, if is for program flow. Therefore guard can make execution faster.
== or === == checks if values are the same, comparing value types. === compares reference types, seeing if they are identical which means that they are at the same memory address.
CollectionView vs TableView A tableview is a list of items in a single column, CollectionView is similar but has multiple rows and columns.
Computed property does not store a value but retrieves and sets other properties and values indirectly.
Content hugging, compressions resistance Content hugging cannot grow, compression resistance cannot shrink.
Downcasting as is used for upcasting, as? is used for safecasting and as! used to force cast.
Forced unwrapping When we have an optional, to use it we need to unwrap it. This means putting ! at the end, and we need to guarantee that the optional is not nil as if it is we will encounter a crash.
Guard Guard can avoid the pyramid of doom and provide early exits.
Initialization prepare a struct, class or enum for use. Stored properties cannot be left in an indeterminate state, can have convenience and custom intializers or the default initializer.
inout inout passes by reference, a regular parameter passes by value.
Main thread where all UI work should be.
Nil coalescing operator ??
Optional binding if let.
Optional chaining If any optional is nil, the entire chain fails gracefully
Stored property let or var
Tenary Operator ? :
Transition from not running An App moves from not running, briefly through inactive through the active (and possibly the background state) when launched.
Transition to being suspended An App moves briefly to background while being .
UIKit Used to develop the user interface for iOS.
Advantages of Swift Optionals, error handling, closures, type safety, speed, ARC, dynamic library, pattern matching, playground.
Class hierarchy for UIButton UIButton> UIControl> UIView> UIResponder> NSObject.
Closures or blocks Closures captures variables that are mutable rather than copied. Objective-C blocks are compatible so closures can be passed to blocks.
Defer usage enables out of order statements, and can be used around opening and closing a context within a scope.
Faster iteration NSSet NSArray NSarray is faster since the access time is O(1), and NSSet is O(1) amortized.
KVC (Key-Value Coding) A mechanism by which an objects properties can be accessed indirectly.
Stack or Heap Stack is fast access, variables stored and cannot be resized. Heap can be access globally with slow access but no memory limit. We manage the memory on the heap.
Type Annotation Explicity define the type using a colon:
Type Inference Swift can infer the type of anything you write.
Type Safety cannot incorrectly mix types. Swift is type safe.
A Bit more challenging
Core Data Core Data is an object graph and persistence framework. Operates on data stored in memory, requires a save process and leaves data constraints to the business logic side of the program.
Extensions in Swift can add computed instance properties and computed properties, define instance methods, provide new initialisers, define subscripts, define new nested types and make an existing type conform to a protocol.
GCD or NSOperation GCD is low level, and is simple. NSOperation allows more granularity (cancelling, dependencies, observable).
How to create a screen that depends on two API calls. Could use booleans, but that is a poor solution, dispatch group is much better.
Implicitly assigned raw values when you use an enum to store integer or string raw values you do not have to assign a raw value for each case.
push or modal segue Push pushes a view on the navigation stack. Modal presents on top of the current view controller.
Responder chain the responder chain is a series of linked responder objects. If the first responder cannot handle an event, it forwards it to the next responder in the chain.
typealias is a named alias of an existing type, so allow a new name to refer to an existing type.
Type Properties properties can be declared with the static keyword that apply to the type rather than an instance of that type.
unwind segue An unwind segue moves backwards through one or more segues to return the user to a scene managed by an existing view controller.
weak self and unowned self weak handles the case it might be nil without holding onto a strong link. Unowned does the same, but the variable cannot be nil.
Auto layout Calculates the size and the position of all the views in the view hierarchy, based on constraints. The views can dynamically respond to both internal and external changes. External changes can be rotations, and internal changes can be changes in content. One power of using stack views is to leverage the power of Auto Layout without introducing the complexity of constraints. Autolayout equations are equality, not assignment and have to be resolved.
Pattern matching Tuples, type-casting, wildcards, option, enumeration case, expression.
Lazy stored property a property that is calculated only when the property is called the first time (can’t use with let, can’t use computed properties, must be a member of a struct or a class, and not thread safe).
Two phase initialization there are four safety checks.
Slightly longer topics
Explain Initializing with closures
If a stored property’s default value requires some customization or setup, you can use a closure or global function to provide a customized default value for that property. Whenever a new instance of the type that the property belongs to is initialized, the closure or function is called, and its return value is assigned as the property’s default value.
Define Capture list ?
If you want to capture the value of a variable at the point of the closure creation, instead of having it evaluate only when the closure executes, you can use a capture list.
Capture lists are written between square brackets right after the closure’s opening bracket (and before the closure’s arguments / return type if any)
To capture the value of a variable at the point of the closure’s creation (instead of a reference to the variable itself), you can use the
[localVar = varToCapture]capture list.
I’ve developed this list over a number of years. You know what, it’s really helped me out.
I really hope that it helps someone else out too — the job market requires that you have a certain competency in technical skills and this list can help you make that barrier.
What else is there? Well, I’ve created a series of artices that can help you out. You’re reading one of them now. Even better might be to hit me up on Twitter you want to ask me anything from the like: HERE.
In any case, good luck with your programming journey!