var name = \"onthecodepath\" /* implicit */"}},{"@type":"Question","name":"What is the difference between weak and strong?","acceptedAnswer":{"@type":"Answer","text":"
First, objects are strong by default.
Strong means that the reference count will be increased and the reference to it will be maintained through the life of the object.
Weak, means that we are pointing to an object but not increasing its reference count. It's often used when creating a parent child relationship. The parent has a strong reference to the child but the child only has a weak reference to the parent.
Common instances of weak references are delegate properties and subview/controls of a view controller's main view since those views are already strongly held by the main view.
"}},{"@type":"Question","name":"What is the difference between category and extension in Objective-C?","acceptedAnswer":{"@type":"Answer","text":"
A category and extension are similar in functionality where they can add additional instance and class methods to a class. However, an extension can only do so if the source code for the class being extended is available at compile time. This means that classes such as NSString cannot be extended. Instead, a category would be used to add additional methods to the NSString class
In the first line above, the name variable is explicitly declared since the type of the variable follows the name of the variable. In the second line, the String type is not explicitly declared. However, Swift is able to infer that name is of a String type since the value that it is being set as is of a String type.
"}},{"@type":"Question","name":"What is KVO?","acceptedAnswer":{"@type":"Answer","text":"KVO stands for Key-Value Observing. It allows a controller or class to observe when a property value changes."}},{"@type":"Question","name":"Design Patterns, name and explain.","acceptedAnswer":{"@type":"Answer","text":"
Singleton Pattern The Singleton design pattern ensures that only one instance exists for a given class and that there's a global access point to that instance. It usually uses lazy loading to create the single instance when it's needed the first time.
Delegation pattern The delegation pattern is a powerful pattern used in building iOS applications. The basic idea is that one object will act on another object's behalf or in coordination with another object. The delegating object typically keeps a reference to the other object (delegate) and sends a message to it at the appropriate time. It is important to note that they have a one to one relationship.
MVC MVC stands for Model-View-Controller. It is a software architecture pattern for implementing user interfaces. MVC consists of three layers: the model, the view, and the controller.
The model layer is typically where the data resides (persistence, model objects, etc)
The view layer is typically where all the UI interface lies. Things like displaying buttons and numbers belong in the view layer. The view layer does not know anything about the model layer and vice versa.
The controller (view controller) is the layer that integrates the view layer and the model layer together.
MVVM MVVM stands for Model-View-ViewModel. It is a software architecture pattern for implementing user interfaces. MVVM is an augmented version of MVC where the presentation logic is moved out of the controller and into the view model. The view model is responsible for handling most, if not all, of the view's display logic. A common occurence in MVC is where you have a massive-view-controller (some joke this is what MVC stands for). In order to shrink the size of your view controller and make the logic and readibility of your code easier to follow along, the MVVM will be used.
"}},{"@type":"Question","name":"What is protocol?","acceptedAnswer":{"@type":"Answer","text":"
A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol.
In addition to specifying requirements that conforming types must implement, you can extend a protocol to implement some of these requirements or to implement additional functionality that conforming types can take advantage of.
"}},{"@type":"Question","name":"Which are the ways of achieving concurrency in iOS?","acceptedAnswer":{"@type":"Answer","text":"
The three ways to achieve concurrency in iOS are:
Threads
Dispatch queues
Operation queues
"}},{"@type":"Question","name":"What is GCD and how is it used?","acceptedAnswer":{"@type":"Answer","text":"
GCD stands for Grand Central Dispatch. It offers the following benefits
Improving your app's responsiveness by helping to defer computationally expensive tasks and run them in the background.
Providing an easier concurrency model than locks and threads and helps to avoid concurrency bugs.
Potentially optimize your code with higher performance primitives for common patterns such as singletons.
In other words, GCD provides and manages queues of tasks in the iOS app. This is one of the most commonly used API to manage concurrent code and execute operations asynchronously. Network calls are often performed on a background thread while things like UI updates are executed on the main thread.
"}},{"@type":"Question","name":"Explain the difference between Serial vs Concurrent","acceptedAnswer":{"@type":"Answer","text":"Tasks executed serially are executed one at a time while tasks that are executed concurrently may be executed at the same time."}},{"@type":"Question","name":"What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view?","acceptedAnswer":{"@type":"Answer","text":"
viewDidLoad is only called when the view is loaded (after loadView is called). viewDidAppear, on the other hand, is called everytime the view appears on the device.
If the data is static for the most part, it can be loaded in viewDidLoad and cached. But if the data is dynamic and likely to change often, it is preferrable to use viewDidAppear. In both instances, data should be loaded asynchronously on a background thread to avoid blocking the UI.
"}},{"@type":"Question","name":"What is the reuseIdentifier for?","acceptedAnswer":{"@type":"Answer","text":"
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.
"}},{"@type":"Question","name":"What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server?","acceptedAnswer":{"@type":"Answer","text":"
Only download the image when the cell is scrolled into view (when cellForRowAtIndexPath is called)
Download the image asynchronously on a background thread so as not to block the UI so the user can keep scrolling
When the image has downloaded for a cell, check if that cell is still in the view or whether it has been re-used by another piece of data. If the cell has been re-used, then the image should be discarded. Otherwise, it should be switched back to the main thread to change the image on the cell.
"}},{"@type":"Question","name":"What is autolayout?","acceptedAnswer":{"@type":"Answer","text":"Auto Layout is used to dynamically calculate the size and position of views based on constraints."}},{"@type":"Question","name":"Types of notification","acceptedAnswer":{"@type":"Answer","text":"
Local notifications and remote notifications are ways to inform users when new data becomes available for an app, even when an app is not running in the foreground. The difference between local and remote notifications is straightforward:
With local notifications, the app configures the notification details locally and passes those details to the system, which then handles the delivery of the notification when the app is not in the foreground. Local notifications are supported on iOS, tvOS, and watchOS.
With remote notifications, one of your company's servers is used to push data to user devices via the Apple Push Notification service. Remote notifications are supported on iOS, tvOS, watchOS, and macOS.
"}},{"@type":"Question","name":"iOS Data Storage options","acceptedAnswer":{"@type":"Answer","text":"
NSUserDefaults - meant for storing small pieces of data such as settings, preferences, and individual values
Property List - Property lists are another great way to store our data. However like userDefaults it is not intended to save large amount of data.
Keychain - for saving highly sensitive and secure data like passwords and secret codes.
Saving Files- directly save all types of files to the file system.
CoreData - Apple's solution for persistence, allows applications to persist data of any form and retrieve it. Core Data isn't technically a database, although it usually stores its data in one (an SQLite database, to be precise).
"}},{"@type":"Question","name":"Ways to distribute iOS App","acceptedAnswer":{"@type":"Answer","text":"
Apple provides three ways to distribute your application based on which developer program you are a member of:
App Store or iTunes Store: Publish an application to the iTunes Store.
In House: Publish an application in house for company's employees. Members of the Apple Developer Enterprise program see this option instead of the App Store option.
Ad Hoc: Publish an application as a package that can be distributed on a limited number of devices for testing.