You are on page 1of 84

Core Data Stack:

Managed Object Model – It describes the schema that you use in the app. If you have a database
background, think of this as the database schema. However, the schema is represented by a collection of
objects (also known as entities). In Xcode, the Managed Object Model is defined in a file with the
extension .​xcdatamodeld​. You can use the visual editor to define the entities and their attributes, as well
as, relationships.
Persistent Store Coordinator – SQLite is the default persistent store in iOS. However, Core Data allows
developers to setup multiple stores containing different entities. The Persistent Store Coordinator is the
party responsible to manage different persistent object stores and save the objects to the stores. Forget
about it you don’t understand what it is. You’ll not interact with Persistent Store Coordinator directly when
using Core Data.
Managed Object Context – Think of it as a “scratch pad” containing objects that interacts with data in
persistent store. Its job is to manage objects created and returned using Core Data. Among the
components in the Core Data Stack, the Managed Object Context is the one you’ll work with for most of
the time. In general, whenever you need to fetch and save objects in persistent store, the context is the
first component you’ll talk to.
The below illustration can probably give you a better idea about the Core Data Stack:
Part - 1
1- How could you setup Live Rendering ?
The attribute ​@IBDesignable​ lets Interface Builder perform live updates on a particular view.

2- What is the difference between Synchronous & Asynchronous task ?


Synchronous: waits until the task has completed Asynchronous: completes a task in background and can
notify you when complete

3- What Are B-Trees?


B-trees are search trees that provide an ordered key-value store with excellent performance
characteristics. In principle, each node maintains a sorted array of its own elements, and another array for
its children.

4- What is made up of NSError object?


There are three parts of NSError object a domain, an error code, and a user info dictionary. The domain
is a string that identifies what categories of errors this error is coming from.

5- What is Enum ?
Enum is a type that basically contains a group of related values in same umbrella.

6- What is bounding box?


Bounding box is a term used in geometry; it refers to the smallest measure (area or volume) within which
a given set of points.

7- Why don’t we use strong for enum property in Objective-C ?


Because enums aren’t objects, so we don’t specify strong or weak here.

8- What is @synthesize in Objective-C ?


synthesize generates getter and setter methods for your property.

9- What is @dynamic in Objective-C ?


We use dynamic for subclasses of NSManagedObject. @dynamic tells the compiler that getter and
setters are implemented somewhere else.

10- Why do we use synchronized ?


synchronized guarantees that only one thread can be executing that code in the block at any given time.
11- What is the difference strong, weaks, read only and copy ?
strong, weak, assign property attributes define how memory for that property will be managed.
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.
Read only, we can set the property initially but then it can’t be changed.
Copy, means that we’re copying the value of the object when it’s created. Also prevents its value from
changing.
for ​more details​ check this out

12- What is Dynamic Dispatch ?


Dynamic Dispatch is the process of selecting which implementation of a polymorphic operation that’s a
method or a function to call at run time. This means, that when we wanna invoke our methods like object
method. but Swift does not default to dynamic dispatch

13- What’s Code Coverage ?


Code coverage is a metric that helps us to measure the value of our unit tests.

14- What’s Completion Handler ?


Completion handlers are super convenient when our app is making an API call, and we need to do
something when that task is done, like updating the UI to show the data from the API call. We’ll see
completion handlers in Apple’s APIs like dataTaskWithRequest and they can be pretty handy in your own
code.
The completion handler takes a chunk of code with 3 arguments:(NSData?, NSURLResponse?,
NSError?) that returns nothing: Void. It’s a closure.
The completion handlers have to marked @escaping since they are executed some point after the
enclosing function has been executed.

15- How to Prioritize Usability in Design ?


Broke down its design process to prioritize usability in 4 steps:
● Think like the user, then design the UX.
● Remember that users are people, not demographics.
● When promoting an app, consider all the situations in which it could be useful.
● Keep working on the utility of the app even after launch.

16- What’s the difference between the frame and the bounds?
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to
its own coordinate system (0,0).
The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to
the superview it is contained within.

17- What is Responder Chain ?


A ResponderChain is a hierarchy of objects that have the opportunity to respond to events received.

18- What is Regular expressions ?


Regular expressions are special string patterns that describe how to search through a string.

19- What is Operator Overloading ?


Operator overloading allows us to change how existing operators behave with types that both already
exist.

20- What is TVMLKit ?


TVMLKit is the glue between TVML, JavaScript, and your native tvOS application.

21- What is Platform limitations of tvOS ?


First, tvOS provides no browser support of any kind, nor is there any WebKit or other web-based
rendering engine you can program against. This means your app can’t link out to a web browser for
anything, including web links, OAuth, or social media sites.
Second, tvOS apps cannot explicitly use local storage. At product launch, the devices ship with either 32
GB or 64 GB of hard drive space, but apps are not permitted to write directly to the on-board storage.
tvOS app bundle cannot exceed 4 GB.

22- What is Functions ?


Functions let us group a series of statements together to perform some task. Once a function is created, it
can be reused over and over in your code. If you find yourself repeating statements in your code, then a
function may be the answer to avoid that repetition.
Pro Tip, Good functions accept input and return output. Bad functions set global variables and rely on
other functions to work.

23- What is ABI ?


ABIs are important when it comes to applications that use external libraries. If a program is built to use a
particular library and that library is later updated, you don’t want to have to re-compile that application
(and from the end-user’s standpoint, you may not have the source). If the updated library uses the same
ABI, then your program will not need to change.
24- Why is design pattern very important ?
Design patterns are reusable solutions to common problems in software design. They’re templates
designed to help you write code that’s easy to understand and reuse. Most common Cocoa design
patterns:
● Creational: Singleton.
● Structural: Decorator, Adapter, Facade.
● Behavioral: Observer, and, Memento

25- What is 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.

26- What is Facade Design Pattern ?


The Facade design pattern provides a single interface to a complex subsystem. Instead of exposing the
user to a set of classes and their APIs, you only expose one simple unified API.

27- What is Decorator Design Pattern ?


The Decorator pattern dynamically adds behaviors and responsibilities to an object without modifying its
code. It’s an alternative to subclassing where you modify a class’s behavior by wrapping it with another
object.
In Objective-C there are two very common implementations of this pattern: ​Category and ​Delegation​. In
Swift there are also two very common implementations of this pattern: ​Extensions​ and ​Delegation​.

28- What is Adapter Pattern ?


An Adapter allows classes with incompatible interfaces to work together. It wraps itself around an object
and exposes a standard interface to interact with that object.

29- What is Observer Pattern ?


In the Observer pattern, one object notifies other objects of any state changes.
Cocoa implements the observer pattern in two ways: Notifications and Key-Value Observing (KVO).

30- What is Memento Pattern ?


In Memento Pattern saves your stuff somewhere. Later on, this externalized state can be restored without
violating encapsulation; that is, private data remains private. One of Apple’s specialized implementations
of the Memento pattern is Archiving other hand iOS uses the Memento pattern as part of State
Restoration.
31- Explain MVC
● Models — responsible for the domain data or a data access layer which manipulates the data,
think of ‘Person’ or ‘PersonDataProvider’ classes.
● Views — responsible for the presentation layer (GUI), for iOS environment think of everything
starting with ‘UI’ prefix.
● Controller/Presenter/ViewModel — the glue or the mediator between the Model and the View, in
general responsible for altering the Model by reacting to the user’s actions performed on the View
and updating the View with changes from the Model.

32- Explain MVVM


UIKit independent representation of your View and its state. The View Model invokes changes in the
Model and updates itself with the updated Model, and since we have a binding between the View and the
View Model, the first is updated accordingly.
Your view model will actually take in your model, and it can format the information that’s going to be
displayed on your view.
There is a more known framework called ​RxSwift​. It contains RxCocoa, which are reactive extensions for
Cocoa and CocoaTouch.

33- How many different annotations available in Objective-C ?


● _Null_unspecified, which bridges to a Swift implicitly unwrapped optional. This is the default.
● _Nonnull, the value won’t be nil it bridges to a regular reference.
● _Nullable the value can be nil, it bridges to an optional.
● _Null_resettable the value can never be nil, when read but you can set it to know to reset it. This
is only apply property.

34- What is JSON/PLIST limits ?


● We create your objects and then serialized them to disk..
● It’s great and very limited use cases.
● We can’t obviously use complex queries to filter your results.
● It’s very slow.
● Each time we need something, we need to either serialize or deserialize it.
● it’s not thread-safe.

35- What is SQLite limits ?


● We need to define the relations between the tables. Define the schema of all the tables.
● We have to manually write queries to fetch data.
● We need to query results and then map those to models.
● Queries are very fast.

36- What is Realm benefits ?


● An open-source database framework.
● Implemented from scratch.
● Zero copy object store.
● Fast.

37- How many are there APIs for battery-efficient location tracking ?
There are 3 apis.
● Significant location changes — the location is delivered approximately every 500 metres (usually
up to 1 km)
● Region monitoring — track enter/exit events from circular regions with a radius equal to 100m or
more. Region monitoring is the most precise API after GPS.
● Visit events — monitor place Visit events which are enters/exits from a place (home/office).

38- What is the Swift main advantage ?


To mention some of the main advantages of Swift:
● Optional Types, which make applications crash-resistant
● Built-in error handling
● Closures
● Much faster compared to other languages
● Type-safe language
● Supports pattern matching

39- Explain generics in Swift ?


Generics create code that does not get specific about underlying data types. Don’t catch this ​article​.

40- Explain lazy in Swift ?


An initial value of the lazy stored properties is calculated only when the property is called for the first time.
There are situations when the lazyproperties come very handy to developers.

41- Explain what is defer ?


defer keyword which provides a block of code that will be executed in the case when execution is leaving
the current scope.
42- How to pass a variable as a reference ?
We need to mention that there are two types of variables: reference and value types. The difference
between these two types is that by passing value type, the variable will create a copy of its data, and the
reference type variable will just point to the original data in the memory.

43- Why it is better to use higher order functions?


Functions that take another function as a parameter, or return a function, as a result, are known as
higher-order functions. Swift defines these functions as CollectionType.
The very basic higher order function is a filter.

44- What is Concurrency ?


Concurrency is dividing up the execution paths of your program so that they are possibly running at the
same time. The common terminology: process, thread, multithreading, and others. Terminology;
● Process, An instance of an executing app
● Thread, Path of execution for code
● Multithreading, Multiple threads or multiple paths of execution running at the same time.
● Concurrency, Execute multiple tasks at the same time in a scalable manner.
● Queues, Queues are lightweight data structures that manage objects in the order of First-in,
First-out (FIFO).
● Synchronous vs Asynchronous tasks

in an NSOperationQueue, the terms concurrent and non-concurrent do not necessarily refer to the
side-by-side execution of threads. Instead, a non-concurrent operation is one that executes using the
environment that is provided for it while a concurrent operation is responsible for setting up its own
execution environment.

The iOS architecture can be broken down into four distinct layers:
● Cocoa Touch
● Media
● Core Services
● Core OS

Core OS - This important layer is in charge of managing memory—allocating and releasing memory once
the application has finished with it, taking care of file system tasks, handling networking, and other
operating system tasks. It also interacts directly with the hardware.
Core Services - Some of the Important Frameworks available in the core services layers.
Graphics, audio, and video are handled by the Media layer.
Cocoa Touch - Multitasking support. – Basic app management and infrastructure. – User interface

management – Support for Touch and Motion event. – Cut, c​opy and paste support and many more. 

45- Grand Central Dispatch (GCD)


GCD is a library that provides a low-level and object-based API to run tasks concurrently while managing
threads behind the scenes. Terminology;
● Dispatch Queues, A dispatch queue is responsible for executing a task in the first-in, first-out
order.
● Serial Dispatch Queue A serial dispatch queue runs tasks one at a time.
● Concurrent Dispatch Queue A concurrent dispatch queue runs as many tasks as it can without
waiting for the started tasks to finish.
● Main Dispatch Queue A globally available serial queue that executes tasks on the application’s
main thread.

46- Readers-Writers
Multiple threads reading at the same time while there should be only one thread writing. The solution to
the problem is a readers-writers lock which allows concurrent read-only access and an exclusive write
access. Terminology;
● Race Condition A race condition occurs when two or more threads can access shared data and
they try to change it at the same time.
● Deadlock A deadlock occurs when two or sometimes more tasks wait for the other to finish, and
neither ever does.
● Readers-Writers problem Multiple threads reading at the same time while there should be only
one thread writing.
● Readers-writer lock Such a lock allows concurrent read-only access to the shared resource while
write operations require exclusive access.
● Dispatch Barrier Block Dispatch barrier blocks create a serial-style bottleneck when working with
concurrent queues.

47- NSOperation — NSOperationQueue — NSBlockOperation
NSOperation adds a little extra overhead compared to GCD, but we can add dependency among various
operations and re-use, cancel or suspend them.
NSOperationQueue, It allows a pool of threads to be created and used to execute NSOperations in
parallel. Operation queues aren’t part of GCD.
NSBlockOperation allows you to create an NSOperation from one or more closures. NSBlockOperations
can have multiple blocks, that run concurrently.

48- KVC — KVO
KVC adds stands for Key-Value Coding. It’s a mechanism by which an object’s properties can be
accessed using string’s at runtime rather than having to statically know the property names at
development time.
KVO stands for Key-Value Observing and allows a controller or class to observe changes to a property
value. In KVO, an object can ask to be notified of any changes to a specific property, whenever that
property changes value, the observer is automatically notified.

49- Please explain Swift’s pattern matching techniques


● Tuple patterns are used to match values of corresponding tuple types.
● Type-casting patterns allow you to cast or match types.
● Wildcard patterns match and ignore any kind and type of value.
● Optional patterns are used to match optional values.
● Enumeration case patterns match cases of existing enumeration types.
● Expression patterns allow you to compare a given value against a given expression.

50- What are benefits of Guard ?


There are two big benefits to guard. One is avoiding the pyramid of doom, as others have
mentioned — lots of annoying if let statements nested inside each other moving further and further to the
right. The other benefit is provide an early exit out of the function using break or using return.

Part - 2

1- Please explain Method Swizzling in Swift


Method Swizzling is a well known practice in Objective-C and in other languages that support dynamic
method dispatching.
Through swizzling, the implementation of a method can be replaced with a different one at runtime, by
changing the mapping between a specific #selector(method) and the function that contains its
implementation.
To use method swizzling with your Swift classes there are two requirements that you must comply with:
● The class containing the methods to be swizzled must extend NSObject
● The methods you want to swizzle must have the dynamic attribute

2- What is the difference Non-Escaping and Escaping Closures ?


The lifecycle of a non-escaping closure is simple:
1. Pass a closure into a function
2. The function runs the closure (or not)
3. The function returns
Escaping closure means, inside the function, you can still run the closure (or not); the extra bit of the
closure is stored some place that will outlive the function. There are several ways to have a closure
escape its containing function:
● Asynchronous execution: If you execute the closure asynchronously on a dispatch queue, the
queue will hold onto the closure for you. You have no idea when the closure will be executed and
there’s no guarantee it will complete before the function returns.
● Storage: Storing the closure to a global variable, property, or any other bit of storage that lives on
past the function call means the closure has also escaped.
for ​more details.

3- Explain [weak self] and [unowned self] ?


unowned does the same as weak with one exception: The variable will not become nil and therefore the
variable must not be an optional.
But when you try to access the variable after its instance has been deallocated. That means, you should
only use unowned when you are sure, that this variable will never be accessed after the corresponding
instance has been deallocated.
However, if you don’t want the variable to be weak AND you are sure that it can’t be accessed after the
corresponding instance has been deallocated, you can use unowned.
By declaring it [weak self] you get to handle the case that it might be nil inside the closure at some point
and therefore the variable must be an optional. A case for using [weak self] in an asynchronous network
request, is in a view controller where that request is used to populate the view.

4- What is ARC ?
ARC is a compile time feature that is Apple’s version of automated memory management. It stands for
Automatic Reference Counting. This means that it only frees up memory for objects when there are zero
strong references/ to them.

5- Explain #keyPath() ?
Using #keyPath(), a static type check will be performed by virtue of the key-path literal string being used
as a StaticString or StringLiteralConvertible. At this point, it’s then checked to ensure that it
A) is actually a thing that exists and
B) is properly exposed to Objective-C.

6- What is iOS 11 SDK Features for Developers ?


● New MapKit Markers
● Configurable File Headers
● Block Based UITableView Updates
● MapKit Clustering
● Closure Based KVO
● Vector UIImage Support
● New MapKit Display Type
● Named colors in Asset Catalog
● Password Autofill
● Face landmarks, Barcode and Text Detection
● Multitasking using the new floating Dock, slide-over apps, pinned apps, and the new App Switcher
● Location Permission: A flashing blue status bar anytime an app is collecting your location data in
the background. Updated locations permissions that always give the user the ability to choose
only to share location while using the app.
for more ​information​.

7- What makes React Native special for iOS?


1. (Unlike PhoneGap) with React Native your application logic is written and runs in JavaScript,
whereas your application UI is fully native; therefore you have none of the compromises typically
associated with HTML5 UI.
2. Additionally (unlike Titanium), React introduces a novel, radical and highly functional approach to
constructing user interfaces. In brief, the application UI is simply expressed as a function of the
current application state.

8- What is NSFetchRequest ?
NSFetchRequest is the class responsible for fetching from Core Data. Fetch requests are both powerful
and flexible. You can use fetch requests to fetch a set of objects meeting the provided criteria, individual
values and more.

9- Explain NSPersistentContainer ?
The persistent container creates and returns a container, having loaded the store for the application to it.
This property is optional since there are legitimate error conditions that could cause the creation of the
store to fail.

10- Explain NSFetchedResultsController ?


NSFetchedResultsController is a controller, but it’s not a view controller. It has no user interface. Its
purpose is to make developers’ lives easier by abstracting away much of the code needed to synchronize
a table view with a data source backed by Core Data.
Set up an NSFetchedResultsController correctly, and your table will mimic its data source without you
have to write more than a few lines of code.

11- What is the three major debugging improvements in Xcode 8 ?


● The View Debugger lets us visualize our layouts and see constraint definitions at runtime.
Although this has been around since Xcode 6, Xcode 8 introduces some handy new warnings for
constraint conflicts and other great convenience features.
● The Thread Sanitizer is an all new runtime tool in Xcode 8 that alerts you to threading
issues — most notably, potential race conditions.
● The Memory Graph Debugger is also brand new to Xcode 8. It provides visualization of your app’s
memory graph at a point in time and flags leaks in the Issue navigator.

12- What is the Test Driven Development of three simple rules ?


1. You are not allowed to write any production code unless it is to make a failing unit test pass.
2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation
failures are failures.
3. You are not allowed to write any more production code than is sufficient to pass the one failing
unit test.

13- Please explain final keyword into the class ?


By adding the keyword final in front of the method name, we prevent the method from being overridden. If
we can replace the final class keyword with a single word static and get the same behavior.

14- What does Yak Shaving mean ?


Yak shaving is a programing term that refers to a series of tasks that need to be performed before a
project can progress to its next milestone.

15- What is the difference open & public access level ?


open allows other modules to use the class and inherit the class; for members, it allows others modules
to use the member and override it.
public only allows other modules to use the public classes and the public members. Public classes can no
longer be subclassed, nor public members can be overridden.

16- What is the difference fileprivate, private and public private(set) access level ?
fileprivate is accessible within the current file, private is accessible within the current declaration.
public private(set) means getter is public, but the setter is private.

17- What is Internal access ?


Internal access enables entities to be used within any source file from their defining module, but not in
any source file outside of the module.
Internal access is the default level of access. So even though we haven’t been writing any access control
specifiers in our code, our code has been at an internal level by default.
18- What is difference between BDD and TDD ?
The main difference between BDD and TDD is the fact that BDD test cases can be read by
non-engineers, which can be very useful in teams.
iOS I prefer ​Quick​ BDD framework and its “matcher framework,” called ​Nimble​.

19- Please explain “Arrange-Act-Assert”


AAA is a pattern for arranging and formatting code in Unit Tests. If we were to write XCTests each of our
tests would group these functional sections, separated by blank lines:
● Arrange all necessary preconditions and inputs.
● Act on the object or method under test.
● Assert that the expected results have occurred.

20- What is the benefit writing tests in iOS apps ?


● Writing tests first gives us a clear perspective on the API design, by getting into the mindset of
being a client of the API before it exists.
● Good tests serve as great documentation of expected behavior.
● It gives us confidence to constantly refactor our code because we know that if we break anything
our tests fail.
● If tests are hard to write its usually a sign architecture could be improved. Following RGR (
Red — Green — Refactor ) helps you make improvements early on.

21- What is five essential practical guidelines to improve your typographic quality of mobile product
designs ?
1. Start by choosing your body text typeface.
2. Try to avoid mixing typefaces.
3. Watch your line length.
4. Balance line height and point size.
5. Use proper Apostrophes and Dashes.

22- Explain Forced Unwrapping


When we defined a variable as optional, then to get the value from this variable, we will have to unwrap it.
This just means putting an exclamation mark at the end of the variable.

23- How to educate app with Context ?


Education in context technique helping users interact with an element or surface in a way they have not
done so previously. This technique often includes slight visual cues and subtle animation.

24- What is bitcode ?


Bitcode refers to to the type of code: “LLVM Bitcode” that is sent to iTunes Connect. This allows Apple to
use certain calculations to re-optimize apps further (e.g: possibly downsize executable sizes). If Apple
needs to alter your executable then they can do this without a new build being uploaded.

25- Explain Swift Standart Library Protocol ?


There are a few different protocol. ​Equatable protocol, that governs how we can distinguish between two
instances of the same type. That means we can analyze. If we have a specific value is in our array. The
comparable protocol, to compare two instances of the same type and ​sequence protocol: prefix(while:)
and drop(while:) [​SE-0045​].
Swift 4 introduces a new Codable protocol that lets us serialize and deserialize custom data types without
writing any special code.

26- What is the difference SVN and Git ?


SVN relies on a centralised system for version management. It’s a central repository where working
copies are generated and a network connection is required for access.
Git relies on a distributed system for version management. You will have a local repository on which you
can work, with a network connection only required to synchronise.

27- What is the difference CollectionViews & TableViews ?


TableViews display a list of items, in a single column, a vertical fashion, and limited to vertical scrolling
only.
CollectionViews also display a list of items, however, they can have multiple columns and rows.

28- What is Alamofire doing ?


Alamofire uses URL Loading System in the background, so it does integrate well with the Apple-provided
mechanisms for all the network development. This means, It provides chainable request/response
methods, JSON parameter and response serialization, authentication, and many other features. It has
thread mechanics and execute requests on a background thread and call completion blocks on the main
thread.

29- REST, HTTP, JSON — What’s that?


HTTP is the application protocol, or set of rules, web sites use to transfer data from the web server to
client. The client (your web browser or app) use to indicate the desired action:
● GET: Used to retrieve data, such as a web page, but doesn’t alter any data on the server.
● HEAD: Identical to GET but only sends back the headers and none of the actual data.
● POST: Used to send data to the server, commonly used when filling a form and clicking submit.
● PUT: Used to send data to the specific location provided.
● DELETE: Deletes data from the specific location provided.
REST, or REpresentational State Transfer, is a set of rules for designing consistent, easy-to-use and
maintainable web APIs.
JSON stands for JavaScript Object Notation; it provides a straightforward, human-readable and portable
mechanism for transporting data between two systems. Apple supplies the JSONSerialization class to
help convert your objects in memory to JSON and vice-versa.

30- What problems does delegation solve?


● Avoiding tight coupling of objects
● Modifying behavior and appearance without the need to subclass objects
● Allowing tasks to be handed off to any arbitrary object

31- What is the major purposes of Frameworks?


Frameworks have three major purposes:
● Code encapsulation
● Code modularity
● Code reuse
You can share your framework with your other apps, team members, or the iOS community. When
combined with Swift’s access control, frameworks help define strong, testable interfaces between code
modules.

32- Explain Swift Package Manager


The Swift Package Manager will help to vastly improve the Swift ecosystem, making Swift much easier to
use and deploy on platforms without Xcode such as Linux. The Swift Package Manager also addresses
the problem of ​dependency hell​ that can happen when using many interdependent libraries.
The Swift Package Manager only supports using the master branch. Swift Package Manager now
supports packages with Swift, C, C++ and Objective-C.

33- What is the difference between a delegate and an NSNotification?


Delegates and NSNotifications can be used to accomplish nearly the same functionality. However,
delegates are one-to-one while NSNotifications are one-to-many.

34- Explain SiriKit Limitations


● SiriKit cannot use all app types
● Not a substitute for a full app only an extension
● Siri requires a consistent Internet connection to work
● Siri service needs to communicate Apple Servers.

35- Why do we use a delegate pattern to be notified of the text field’s events?
Because at most only a single object needs to know about the event.

36- How is an inout parameter different from a regular parameter?


A Inout passes by reference while a regular parameter passes by value.

37- Explain View Controller Lifecycle events order ?


There are a few different lifecycle event
- loadView : Creates the view that the controller manages. It’s only called when the view controller is
created and only when done programatically.
- viewDidLoad : Called after the controller’s view is loaded into memory. It’s only called when the view is
created.
- viewWillAppear : It’s called whenever the view is presented on the screen. In this step the view has
bounds defined but the orientation is not applied.
- viewWillLayoutSubviews :Called to notify the view controller that its view is about to layout its subviews.
This method is called every time the frame changes
- viewDidLayoutSubviews : Called to notify the view controller that its view has just laid out its subviews.
Make additional changes here after the view lays out its subviews.
- viewDidAppear : Notifies the view controller that its view was added to a view hierarchy.
- viewWillDisappear : Before the transition to the next view controller happens and the origin view
controller gets removed from screen, this method gets called.
- viewDidDisappear : After a view controller gets removed from the screen, this method gets called. You
usually override this method to stop tasks that are should not run while a view controller is not on screen.

38- What is the difference between LLVM and Clang?


Clang is the front end of LLVM tool chain ( ​“clang” C Language Family Frontend for LLVM ). Every
Compiler​ has three parts .
1. Front end ( lexical analysis, parsing )
2. Optimizer ( Optimizing abstract syntax tree )
3. Back end ( machine code generation )
Front end ( Clang ) takes the source code and generates abstract syntax tree ( LLVM IR ).

39- What is Class ?


A class is meant to define an object and how it works. In this way, a class is like a blueprint of an object.

40- What is Object?


An object is an instance of a class.

41- What is interface?


The @interface in Objective-C has nothing to do with Java interfaces. It simply declares a public interface
of a class, its public API.

42- When and why do we use an object as opposed to a struct?


Structs are value types. Classes(Objects) are reference types.

43- What is UIStackView?


UIStackView provides a way to layout a series of views horizontally or vertically. We can define how the
contained views adjust themselves to the available space. Don’t miss this ​article​.

44- What are the states of an iOS App?


1. Non-running — The app is not running.
2. Inactive — The app is running in the foreground, but not receiving events. An iOS app can be
placed into an inactive state, for example, when a call or SMS message is received.
3. Active — The app is running in the foreground, and receiving events.
4. Background — The app is running in the background, and executing code.
5. Suspended — The app is in the background, but no code is being executed.

Most state transitions are accompanied by a corresponding call to the methods of your app delegate
object. These methods are your chance to respond to state changes in an appropriate way. These
methods are listed below, along with a summary of how you might use them.
● application:willFinishLaunchingWithOptions:​—This method is your app’s first chance to execute
code at launch time.
● application:didFinishLaunchingWithOptions:​—This method allows you to perform any final
initialization before your app is displayed to the user.
● applicationDidBecomeActive:​—Lets your app know that it is about to become the foreground app.
Use this method for any last minute preparation.
● applicationWillResignActive:​—Lets you know that your app is transitioning away from being the
foreground app. Use this method to put your app into a quiescent state.
● applicationDidEnterBackground:​—Lets you know that your app is now running in the background
and may be suspended at any time.
● applicationWillEnterForeground:​—Lets you know that your app is moving out of the background
and back into the foreground, but that it is not yet active.
● applicationWillTerminate:​—Lets you know that your app is being terminated. This method is not
called if your app is suspended.
45- What are the most important application delegate methods a developer should handle ?
The operating system calls specific methods within the application delegate to facilitate transitioning to
and from various states. The seven most important application delegate methods a developer should
handle are:
application:willFinishLaunchingWithOptions -- Method called when the launch process is initiated. This is
the first opportunity to execute any code within the app.
application:didFinishLaunchingWithOptions -- Method called when the launch process is nearly complete.
Since this method is called is before any of the app’s windows are displayed, it is the last opportunity to
prepare the interface and make any final adjustments.
applicationDidBecomeActive -- Once the application has become active, the application delegate will
receive a callback notification message via the method applicationDidBecomeActive. This method is also
called each time the app returns to an active state from a previous switch to inactive from a resulting
phone call or SMS.
applicationWillResignActive -- There are several conditions that will spawn the
applicationWillResignActive method. Each time a temporary event, such as a phone call, happens this
method gets called. It is also important to note that “quitting” an iOS app does not terminate the
processes, but rather moves the app to the background.
applicationDidEnterBackground -- This method is called when an iOS app is running, but no longer in the
foreground. In other words, the user interface is not currently being displayed. According to Apple’s
UIApplicationDelegate Protocol Reference​, the app has approximately five seconds to perform tasks and
return. If the method does not return within five seconds, the application is terminated.
applicationWillEnterForeground -- This method is called as an app is preparing to move from the
background to the foreground. The app, however, is not moved into an active state without the
applicationDidBecomeActive method being called. This method gives a developer the opportunity to
re-establish the settings of the previous running state before the app becomes active.
applicationWillTerminate -- This method notifies your application delegate when a termination event has
been triggered. Hitting the home button no longer quits the application. Force quitting the iOS app, or
shutting down the device triggers the applicationWillTerminate method. This is the opportunity to save the
application configuration, settings, and user preferences.

45- What does code signing do?


Signing our app allows iOS to identify who signed our app and to verify that our app hasn’t been modified
since you signed it. The Signing Identityconsists of a public-private key pair that Apple creates for us.

46- What is the difference between property and instance variable?


A property is a more abstract concept. An instance variable is literally just a storage slot, like a slot in a
struct. Normally other objects are never supposed to access them directly. Usually a property will return
or set an instance variable, but it could use data from several or none at all.

47- How can we add UIKit for Swift Package Manager ?


Swift Package Manager is not supporting UIKit. We can create File Template or Framework for other
projects.

48- Explain difference between SDK and Framework ?


SDK is a set of software development tools. This set is used for creation of applications. Framework is
basically a platform which is used for developing software applications. It provides the necessary
foundation on which the programs can be developed for a specific platform. SDK and Framework
complement each other, and SDKs are available for frameworks.

49- What is Downcasting ?


When we’re casting an object to another type in Objective-C, it’s pretty simple since there’s only one way
to do it. In Swift, though, there are two ways to cast — one that’s safe and one that’s not .
● as used for upcasting and type casting to bridged type
● as? used for safe casting, return nil if failed
● as! used to force casting, crash if failed. should only be used when we know the downcast will
succeed.

50- Why is everything in a do-catch block?


In Swift, errors are thrown and handled inside of do-catch blocks.

Part - 3
1- What is Nil Coalescing & Ternary Operator ?
It is an easily return an unwrapped optional, or a default value. If we do not have value, we can set zero
or default value.

2- What kind of JSONSerialization have ReadingOptions ?


● mutableContainers Specifies that arrays and dictionaries are created as variables objects, not
constants.
● mutableLeaves Specifies that leaf strings in the JSON object graph are created as instances of
variable String.
● allowFragments Specifies that the parser should allow top-level objects that are not an instance of
Array or Dictionary.
3- Explain subscripts ?
Classes, structures, and enumerations can define subscripts, which are shortcuts for accessing the
member elements of a collection, list, or sequence.

4- What is DispatchGroup ?
DispatchGroup allows for aggregate synchronization of work. We can use them to submit multiple
different work items and track when they all complete, even though they might run on different queues.
This behavior can be helpful when progress can’t be made until all of the specified tasks are
complete. — ​Apple’s Documentation
The most basic answer: If we need to wait on a couple of asynchronous or synchronous operations
before proceeding, we can use DispatchGroup.

5- What is RGR ( Red — Green — Refactor ) ?


Red, Green and Refactor are stages of the TDD (Test Driven Development).
1. Red: Write a small amount of test code usually no more than seven lines of code and watch it fail.
2. Green: Write a small amount of production code. Again, usually no more than seven lines of code
and make your test pass.
3. Refactor: Tests are passing, you can make changes without worrying. Clean up your code. There
are great workshop notes ​here​.

6- Where do we use Dependency Injection ?


We use a storyboard or xib in our iOS app, then we created IBOutlets. IBOutlet is a property related to a
view. These are injected into the view controller when it is instantiated, which is essentially a form of
Dependency Injection.
There are forms of dependency injection: constructor injection, property injection and method injection.

7- Please explain types of notifications.


There are two type of notifications: Remote and Local. Remote notification requires connection to a
server. Local notifications don’t require server connection. Local notifications happen on device.

8- When is a good time for dependency injection in our projects?


There is a few guidelines that you can follow.
● Rule 1. Is Testability important to us? If so, then it is essential to identify external dependencies
within the class that you wish to test. Once dependencies can be injected we can easily replace
real services for mock ones to make it easy to testing easy.
● Rules 2. Complex classes have complex dependencies, include application-level logic, or access
external resources such as the disk or the network. Most of the classes in your application will be
complex, including almost any controller object and most model objects. The easiest way to get
started is to pick a complex class in your application and look for places where you initialize other
complex objects within that class.
● Rules 3. If an object is creating instances of other objects that are shared dependencies within
other objects then it is a good candidate for a dependency injection.

9- What kind of order functions can we use on collection types ?


● map(_:): Returns an array of results after transforming each element in the sequence using the
provided closure.
● filter(_:): Returns an array of elements that satisfy the provided closure predicate.
● reduce(_:_:): Returns a single value by combining each element in the sequence using the
provided closure.
● sorted(by:): Returns an array of the elements in the sequence sorted based on the provided
closure predicate.
To see all methods available from Sequence, take a look at the ​Sequence docs​.

10- What allows you to combine your commits ?


git squash

11- What is the difference ANY and ANYOBJECT ?


According to Apple’s Swift documentation:
● Any can represent an instance of any type at all, including function types and optional types.
● AnyObject can represent an instance of any class type.
Check out for ​more details​.

12- Please explain SOAP and REST Basics differences ?


Both of them helps us access Web services. ​SOAP relies exclusively on XML to provide messaging
services. SOAP is definitely the heavyweight choice for Web service access. Originally developed by
Microsoft.
REST ( Representational State Transfer ) provides a lighter weight alternative. Instead of using XML to
make a request, REST relies on a simple URL in many cases. REST can use four different HTTP 1.1
verbs (GET, POST, PUT, and DELETE) to perform tasks.

13- What is you favorite Visualize Chart library ?


Charts​ has support iOS,tvOS,OSX The Apple side of the cross platform MPAndroidChart.
Core Plot​ is a 2D plotting framework for macOS, iOS, and tvOS
TEAChart​ has iOS support
A curated list of awesome iOS chart libraries, including Objective-C and Swift
14- Which git command allows us to find bad commits ?
git bisect

15- What is CoreData ?


Core data is an object graph manager which also has the ability to persist object graphs to the persistent
store on a disk. An object graph is like a map of all the different model objects in a typical model view
controller iOS application. CoreData has also integration with Core Spotlight.

16- Could you explain Associatedtype ?


If you want to create Generic Protocol we can use associatedtype. For ​more details​ check this out.

17- Which git command saves your code without making a commit ?
git stash

18- Explain ​Priority Inversion​ and ​Priority Inheritance​.


If high priority thread waits for low priority thread, this is called Priority Inversion. if low priority thread
temporarily inherit the priority of the highest priority thread, this is called Priority Inheritance.

19- What is Hashable ?


Hashable​ allows us to use our objects as keys in a dictionary. So we can make our custom types.

20- When do you use optional chaining vs. if let or guard ?


We use optional chaining when we do not really care if the operation fails; otherwise, we use if let or
guard. Optional chaining lets us run code only if our optional has a value.
Using the question mark operator like this is called optional chaining. Apple’s ​documentation explains it
like this:
Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional
that might currently be nil. If the optional contains a value, the property, method, or subscript call
succeeds; if the optional is nil, the property, method, or subscript call returns nil. Multiple queries can be
chained together, and the entire chain fails gracefully if any link in the chain is nil.

21- How many different ways to pass data in Swift ?


There are many different ways such as Delegate, KVO, Segue, and NSNotification, Target-Action,
Callbacks.

22- How do you follow up clean code for this project ?


I follow style guide and coding conventions for Swift projects of ​Github​ and ​SwiftLint​.
23- Explain to using Class and Inheritance benefits
● With Overriding provides a mechanism for customization
● Reuse implementation
● Subclassing provides reuse interface
● Modularity
● Subclasses provide dynamic dispatch

24- What’s the difference optional between nil and .None?


There is no difference. Optional.None (.None for short) is the correct way of initializing an optional
variable lacking a value, whereas nil is just syntactic sugar for .None. Check this ​out​.

25- What is GraphQL ?


GraphQL is trying to solve creating a query interface for the clients at the application level. ​Apollo iOS is a
strongly-typed, caching GraphQL client for iOS, written in Swift.

26- Explain Common features of Protocols & superclasses


● implementation reuse
● provide points for customization
● interface reuse
● supporting modular design via dynamic dispatch on reused interfaces

27- What is ​Continuous Integration​ ?


Continuous Integration allows us to get early feedback when something is going wrong during application
development. There are a lot of continuous integration tools available.
Self hosted server
● Xcode Server
● Jenkins
● TeamCity
Cloud solutions
● TravisCI
● Bitrise
● Buddybuild

28- What is the difference Delegates and Callbacks ?


The difference between delegates and callbacks is that with delegates, the NetworkService is telling the
delegate “There is something changed.” With callbacks, the delegate is observing the NetworkService.
Check this out.

29- Explain Linked List


Linked List basically consist of the structures we named the Node. These nodes basically have two
things. The first one is the one we want to keep. (we do not have to hold single data, we can keep as
much information as we want), and the other is the address information of the other node.
Disadvantages of Linked Lists, at the beginning, there is extra space usage. Because the Linked List
have an address information in addition to the existing information. This means more space usage.

30- Do you know Back End development ?


Depends. I have experienced PARSE and I am awarded FBStart. I decided to learn pure back end. You
have two choices. Either you can learn node.js + express.js and mongodb. OR, you can learn ​Vapor or
Kitura​.
Don’t you like or use Firebase?
Firebase doesn't have a path for macOS X developers.
If you want to learn Firebase, please just follow one month of ​Firebase Google Group​.

31- Explain AutoLayout


AutoLayout provides a flexible and powerful layout system that describes how views and the UI controls
calculates the size and position in the hierarchy.

32- What is the disadvantage to hard-coding log statements ?


First, when you start to log. This starts to accumulate. It may not seem like a lot, but every minute adds
up. By the end of a project, those stray minutes will equal to hours.
Second, Each time we add one to the code base, we take a risk of injecting new bugs into our code.

33- What is Pointer ?


A pointer is a direct reference to a memory address. Whereas a variable acts as a transparent container
for a value, pointers remove a layer of abstraction and let you see how that value is stored.

34- Explain Core ML Pros and Cons


Pros of Core ML:
● Really easy to add into your app.
● Not just for deep learning: also does logistic regression, decision trees, and other “classic”
machine learning models.
● Comes with a handy converter tool that supports several different training packages (Keras, Caffe,
scikit-learn, and others).
Cons:
● Core ML only supports a limited number of model types. If you trained a model that does
something Core ML does not support, then you cannot use Core ML.
● The conversion tools currently support only a few training packages. A notable omission is
TensorFlow, arguably the most popular machine learning tool out there. You can write your own
converters, but this isn’t a job for a novice. (The reason TensorFlow is not supported is that it is a
low-level package for making general computational graphs, while Core ML works at a much
higher level of abstraction.)
● No flexibility, little control. The Core ML API is very basic, it only lets you load a model and run it.
There is no way to add custom code to your models.
● iOS 11 and later only.
For more ​information.

35- What is pair programming?


Pair programming is a tool to share information with junior developers. Junior and senior developer sitting
side-by-side this is the best way for the junior to learn from senior developers.
Check out Martin Fowler on ​“Pair Programming Misconceptions”​, WikiHow on ​Pair Programming

36- Explain blocks


Blocks are a way of defining a single task or unit of behavior without having to write an entire Objective-C
class. they are anonymous functions.

37- What is Keychain ?


Keychain is an API for persisting data securly in iOS App. There is a good library - ​Locksmith

38- What is the biggest changes in UserNotifications ?


● We can add audio, video and images.
● We can create custom interfaces for notifications.
● We can manage notifications with interfaces in the notification center.
● New Notification extensions allow us to manage remote notification payloads before they’re
delivered.

39- Explain the difference between atomic and nonatomic synthesized properties
atomic : It is the default behaviour. If an object is declared as atomic then it becomes thread-safe.
Thread-safe means, at a time only one thread of a particular instance of that class can have the control
over that object.
nonatomic: It is not thread-safe. We can use the nonatomic property attribute to specify that synthesized
accessors simply set or return a value directly, with no guarantees about what happens if that same value
is accessed simultaneously from different threads. For this reason, it’s faster to access a nonatomic
property than an atomic one.

40- Why do we use ​availability​ attributes ?


Apple wants to support one system version back, meaning that we should support iOS9 or iOS8.
Availability Attributes​ lets us to support previous version iOS.

41- How could we get device token ?


There are two steps to get device token. First, we must show the user’s permission screen, after we can
register for remote notifications. If these steps go well, the system will provide device token. If we uninstall
or reinstall the app, the device token would change.

42- What is Encapsulation ?


Encapsulation is an object-oriented design principles and hides the internal states and functionality of
objects. That means objects keep their state information private.

43- What is big-o notation ?


An algorithm is an impression method used to determine the working time for an input N size. The big-o
notation grade is expressed by the highest value. And the big-o notation is finding the answer with the
question of O(n). Here is a ​cheat sheet​ and ​swift algorithm club​. For example;
For Loops big-o notation is O(N). Because For Loops work n times.
Variables (var number:Int = 4) big-o notation is O(1).

44- What Is Dependency Management?


If we want to integrate open source project, add a framework from a third party project, or even reuse
code across our own projects, dependency management helps us to manage these relationships. ​Check
this out

45- What is UML Class Diagrams?


UML Class Diagram is a set of rules and notations for the specification of a software system, managed
and created by the Object Management Group.

46- Explain throw


We are telling the compiler that it can throw errors by using the throws keyword. Before we can throw an
error, we need to make a list of all the possible errors you want to throw.
47- What is Protocol Extensions?
We can adopt protocols using extensions as well as on the original type declaration. This allows you to
add protocols to types you don’t necessarily own.

48- What is three triggers for a local notification ?


Location, Calendar, and Time Interval. A Location notification fires when the GPS on your phone is at a
location or geographic region. Calendar trigger is based on calendar data broken into date components.
Time Interval is a count of seconds until the timer goes off.

49- Explain Selectors in ObjC


Selectors are Objective-C’s internal representation of a method name.

50- What is Remote Notifications attacment’s limits ?


We can be sent with video or image with push notification. But maximum payload is 4kb. If we want to
sent high quality attachment, we should use Notification Service Extension.

Part - 4

1- What Widgets can not do ?


● No keyboard entry
● Scroll views and multistep actions are discouraged

2- What are the limits of accessibility ?


We can not use Dynamic Text with accessibility features.

3- What is ARC and how is it different from AutoRelease?


Autorelease is still used ARC. ARC is used inside the scope, autorelease is used outside the scope of the
function.

4- Explain differences between Foundation and CoreFoundation


The Foundation is a gathering of classes for running with numbers, strings, and collections. It also
describes protocols, functions, data types, and constants. CoreFoundation is a C-based alternative to
Foundation. Foundation essentially is a CoreFoundation. We have a free bridge with NS counterpart.

5- What’s accessibilityHint?
accessibilityHint describes the results of interacting with a user interface element. A hint should be
supplied only if the result of an interaction is not obvious from the element’s label.
6- Explain place holder constraint
This tells Interface Builder to go ahead and remove the constraints when we build and run this code. It
allows the layout engine to figure out a base layout, and then we can modify that base layout at run time.

7- Are you using CharlesProxy ? Why/why not ?


If I need a proxy server that includes both complete requests and responses and the HTTP headers then
I am using ​CharlesProxy​. With CharlesProxy, we can support binary protocols, rewriting and traffic
throttling.

8- Explain 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.

9- What is the relation between iVar and @property?


iVar is an instance variable. It cannot be accessed unless we create accessors, which are generated by
@property. iVar and its counterpart @property can be of different names.
iVar is always can be accessed using KVC.

10- Explain UNNotification Content


UNNotification Content stores the notification content in a scheduled or delivered notification. It is
read-only.

11- What’s the difference between Android and iOS designs?


● Android uses icons, iOS mostly uses text as their action button. When we finish an action, on
Android you will see a checkmark icon, whereas on iOS you’ll have a ‘Done’ or ‘Submit’ text at the
top.
● iOS uses subtle gradients, Android uses flat colors and use different tone/shades to create
dimension. iOS uses bright, vivid colors — almost neon like. Android is colorful, but not as vivid.
● iOS design is mostly flat, but Android’s design is more dimensional. Android adds depth to their
design with floating buttons, cards and so on.
● iOS menu is at the bottom, Android at the top. Also a side menu/hamburger menu is typically
Android. iOS usually has a tab called ‘More’ with a hamburger icon, and that’s usually the menu &
settings rolled into one.
● Android ellipsis icon (…) to show more options is vertical, iOS is horizontal.
● Android uses Roboto and iOS uses San Francisco font
● Frosted glass effect used to be exclusive to iOS, but you’ll see a lot of them in Android too
nowadays. As far as I know it’s still a hard effect to replicate in Android.
● Android usually has navigation button in color, whereas iOS is usually either white or gray.

12- What is Webhooks ?


Webhooks allow external services to be notified when certain events happen within your repository.
(push, pull-request, fork)

13- Explain xcscontrol command


We can manage Xcode Server activities ( start, stop, restart). Also we can reset Xcode Server using the
command below
$ sudo xcrun xcscontrol --reset

14- Explain CAEmitterLayer and CAEmitterCell


UIKit provides two classes for creating particle effects: CAEmitterLayer and CAEmitterCell. The
CAEmitterLayer is the layer that emits, animates and renders the particle system. The CAEmitterCell
represents the source of particles and defines the direction and properties of the emitted particles.

15- Why do we need to specify self to refer to a stored property or a method When writing asynchronous
code?
Since the code is dispatched to a background thread we need to capture a reference to the correct object.

16- Explain NSManagedObjectContext


Its primary responsibility is to manage a collection of managed objects.

17- Explain service extension


The service extension lets us the chance to change content in the notification before it is presented.

18- Explain content extension


The content extension gives us the tools, we have in an app to design the notification.

19- What is intrinsic content size?


Every view that contains content can calculate its intrinsic content size. The intrinsic content size is
calculated by a method on every UIView instance. This method returns a CGSize instance.

20- What is Instruments?


Instrument is a powerful performance tuning tool to analyze that performance, memory footprint, smooth
animation, energy usage, leaks and file/network activity.
21- What is Deep Linking?
Deep linking is a way to pass data to your application from any platform like, website or any other
application. By tapping once on link, you can pass necessary data to your application.

22- What is Optional Binding ?


We are going to take optional value and we are going to bind it non optional constant. We used If let
structure or Guard statement.

23- Explain super keyword in child class


We use the super keyword to call the parent class initializer after setting the child class stored property.

24- Explain Polymorphism


Polymorphism is the ability of a class instance to be substituted by a class instance of one of its
subclasses.

25- Explain In-app Purchase products and subscriptions


● Consumable products: can be purchased more than once and used items would have to
re-purchase.
● Non-consumable products: user would be able to restore this functionality in the future, should
they need to reinstall the app for any reason. We can also add subscriptions to our app.
● Non-Renewing Subscription: Used for a certain amount of time and certain content.
● Auto-Renewing Subscription: Used for recurring monthly subscriptions.

26- What is HealthKit ?


HealthKit is a framework on iOS. It stores health and fitness data in a central location. It takes in data
from multiple sources, which could be different devices. It allows users to control access to their data and
maintains privacy of user data. Data is synced between your phone and your watch.

27- What is Protocol?


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.
The Swift Programming Language Guide by Apple

28- Explain Neural networks with Core ML


Neural networks and deep learning currently provide the best solutions to many problems in image
recognition, speech recognition, and natural language processing.
Core ML is an iOS framework comes with iOS 11, helps to process models in your apps for face
detection. For more information follow this guideline ​https://developer.apple.com/machine-learning/

29- Explain libssl_iOS and libcrypto_iOS


These files are going to help us with on device verification of our receipt verification files with In-App
purchases.

30- Explain JSONEncoder and JSONDecoder in Swift4


JSONEncoder and JSONDecoder classes which can easily convert an object to encoded JSON
representation. Check out ​this​ link

31- What is CocoaTouch ?


CocoaTouch is a library used to build executable applications on iOS. CocoaTouch is an abstract layer on
the iOS.

32- What is NotificationCenter ?


NotificationCenter is an observer pattern, The NSNotificationCenter singleton allows us to broadcast
information using an object called NSNotification.
The biggest difference between KVO and NotificationCenter is that KVO tracks specific changes to an
object, while NotificationCenter is used to track generic events.

33- Why is inheritance bad in swift?


● We cannot use superclasses or inheritance with Swift value types.
● Upfront modelling
● Customization for inheritance is an imprecise
For more information ​check this out

34- Explain Sequence in Swift


Sequence is a basic type in Swift for defining an aggregation of elements that distribute sequentially in a
row. All collection types inherit from Sequence such as Array, Set, Dictionary.

35- What is Receipt Validation ?


The receipt for an application or in-app purchase is a record of the sale of the application and of any
in-app purchases made from within the application. You can add receipt validation code to your
application to prevent unauthorized copies of your application from running.

36- Explain generic function zip(_:_:)


According to the swift documentation, zip creates a sequence of pairs built out of two underlying. That
means, we can create a dictionary includes two arrays.

37- What kind of benefits does Xcode server have for developers?
Xcode server will automatically check out our project, build the app, run tests, and archive the app for
distribution.

38- What is Xcode Bot?


Xcode Server uses bots to automatically build your projects. A bot represents a single remote repository,
project, and scheme. We can also control the build configuration the bot uses and choose which devices
and simulators the bot will use.

39- Explain .gitignore


.gitignore is a file extension that you tell Git server about document types, and folders that you do not
want to add to the project or do not want to track changes made in Git server projects.

40- What is Strategy Pattern?


Strategy pattern allows you to change the behaviour of an algorithm at run time. Using interfaces, we are
able to define a family of algorithms, encapsulate each one, and make them interchangeable, allowing us
to select which algorithm to execute at run time. For more information ​check this out.

41- What is an “app ID” and a “bundle ID” ?


A bundle ID is the identifier of a single app. For example, if your organization’s domain is xxx.com and
you create an app named Facebook, you could assign the string com.xxx.facebook as our app’s bundle
ID.
An App ID is a two-part string used to identify one or more apps from a single development team. You
need Apple Developer account for an App ID.

42- What is Factory method pattern?


Factory method pattern makes the codebase more flexible to add or remove new types. To add a new
type, we just need a new class for the type and a new factory to produce it like the following code. For
more information ​check this out​.
43- What is CoreSpotlight?
CoreSpotlight allows us to index any content inside of our app. While NSUserActivity is useful for saving
the user’s history, with this API, you can index any data you like. It provides access to the CoreSpotlight
index on the user’s device.

44- What are layer objects?


Layer objects are data objects which represent visual content and are used by views to render their
content. Custom layer objects can also be added to the interface to implement complex animations and
other types of sophisticated visual effects.

45- Explain AVFoundation framework


We can create, play audio and visual media. AVFoundation allows us to work on a detailed level with
time-based audio-visual data. With it, we can create, edit, analyze, and re-encode media files.
AVFoundation has two sets of API, one that’s video, and one that is audio.

46- What’s the difference between accessibilityLabel and accessibilityIdentifier?


accessibilityLabel is the value that’s read by VoiceOver to the end-user. As such, this should be a
localized string. The text should also be capitalized. Because this helps with VoiceOver’s pronunciation.
accessibilityLabel is used for testing and Visual Impaired users.
accessibilityIdentifier identifies an element via accessibility, but unlike accessibilityLabel,
accessibilityIdentifier's purpose is purely to be used as an identifier for UI Automation tests. We use a
value for testing process.

47- How to find the distance between two points (1x, 1y and 2x, 2y)?
We need to calculate the distance between the points, we can omit the sqrt() which will make it a little
faster. This question’s background is ​Pythagorean theorem​. We can find the result with ​CGPoint​.
p1
|\
|\
| \H
| \
| \
|_ _ _\p2

48- Explain Property Observer


A ​property observer observes and responds to changes in a property’s value. With property observer, we
don’t need to reset the controls, every time attributes change.
49- What’s the difference between a xib and a storyboard?
Both are used in Xcode to layout screens (view controllers). A xib defines a single View or View Controller
screen, while a storyboard shows many view controllers and also shows the relationship between them.

50- Explain how to add frameworks in Xcode project?


● First, choose the project file from the project navigator on the left side of the project window
● Then choose the target where you want to add frameworks in the project settings editor
● Choose the “Build Phases” tab, and select “Link Binary With Libraries” to view all of the
frameworks
● To add frameworks click on “+” sign below the list select framework and click on add button.

14 - Essential iOS Interview Questions

1. Consider the following UITableViewCell constructor:


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
What is the purpose of the reuseIdentifier? What is the advantage of setting it to a non-nil value?

The reuseIdentifier is used to group together similar rows in an UITableView; i.e., rows that differ only in
their content, but otherwise have similar layouts.

A UITableView will normally allocate just enough UITableViewCell objects to display the content visible in
the table. If reuseIdentifier is set to a non-nil value, then when the table view is scrolled, UITableView will
first attempt to reuse an already allocated UITableViewCell with the same reuseIdentifier. If
reuseIdentifier has not been set, the UITableView will be forced to allocate new UITableViewCell objects
for each new item that scrolls into view, potentially leading to laggy animations.

2. What are different ways that you can specify the layout of elements in a UIView?
Here are a few common ways to specify the layout of elements in a UIView:

Using InterfaceBuilder, you can add a XIB file to your project, layout elements within it, and then load the
XIB in your application code (either automatically, based on naming conventions, or manually). Also,
using InterfaceBuilder you can create a storyboard for your application.

You can your own code to use NSLayoutConstraints to have elements in a view arranged by Auto Layout.

You can create CGRects describing the exact coordinates for each element and pass them to UIView’s -
(id)initWithFrame:(CGRect)frame method.
3. What is the difference between atomic and nonatomic properties? Which is the default for synthesized
properties? When would you use one vs. the other?

Properties specified as atomic are guaranteed to always return a fully initialized object. This also happens
to be the default state for synthesized properties so, while it’s a good practice to specify atomic to remove
the potential for confusion, if you leave it off, your properties will still be atomic. This guarantee of atomic
properties comes at a cost to performance, however. If you have a property for which you know that
retrieving an uninitialized value is not a risk (e.g. if all access to the property is already synchronized via
other means), then setting it to nonatomic can gain you a bit of performance.

4. Imagine you wanted to record the time that your application was launched, so you created a class that
defined a global variable in its header: NSString *startTime;. Then, in the class’ implementation, you set
the variable as follows:

+ (void)initialize {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
startTime = [formatter stringFromDate:[NSDate date]];
}
If you then added the following line to the application:didFinishLaunchingWithOptions: method in your
AppDelegate:

NSLog(@"Application was launched at: %@", startTime);


what would you expect to be logged in the debugger console? How could you fix this to work as
expected?

The debugger console will log Application was launched at: (null) because the global startTime variable
has not yet been set. The initialize method of an Objective-C class is only called right before the first
message is sent to that class. On the other hand, any load methods defined by Objective-C classes will
be called as soon as the class is added to the Objective-C runtime.

There are a couple different ways to solve this problem.

Way to Solve #1: Changing initialize to load will yield the desired result (but be cautious about doing too
much in load, as it may increase your application’s load time).
Way to Solve #2, thanks to commenter John, there is another way: create another class method on your
created class. Let’s call this new method getStartTime, and all it does is return our global startTime
object.

Now we change our NSLog line to:

NSLog(@"Application was launched at: %@", [OurCreatedClass getStartTime]);


Because we’re now sending a message to OurCreatedClass, its initialize will get called , setting
startTime. The getStartTime method will then be called, and return the start time!

5. Consider the following code:

#import "TTAppDelegate.h"

@interface TTParent : NSObject

@property (atomic) NSMutableArray *children;

@end

@implementation TTParent
@end

@interface TTChild : NSObject

@property (atomic) TTParent *parent;

@end

@implementation TTChild
@end

@implementation TTAppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
TTParent *parent = [[TTParent alloc] init];
parent.children = [[NSMutableArray alloc] init];
for (int i = 0; i < 10; i++) {
TTChild *child = [[TTChild alloc] init];
child.parent = parent;
[parent.children addObject:child];
}
return YES;
}
@end
What is the bug in this code and what is its consequence? How could you fix it?

This is a classic example of a retain cycle. The parent will retain the children array, and the array will
retain each TTChild object added to it. Each child object that is created will also retain its parent, so that
even after the last external reference to parent is cleared, the retain count on parent will still be greater
than zero and it will not be removed.

In order to fix this, the child’s reference back to the parent needs to be declared as a weak reference as
follows:

@interface TTChild : NSObject

@property (weak, atomic) TTParent *parent;

@end
A weak reference will not increment the target’s retain count, and will be set to nil when the target is
finally destroyed.

Note:

For a more complicated variation on this question, you could consider two peers that keep references to
each other in an array. In this case, you will need to substitute NSArray/NSMutableArray with an
NSPointerArray declared as:

NSPointerArray *weakRefArray = [[NSPointerArray alloc] initWithOptions:


NSPointerFunctionsWeakMemory];
since NSArray normally stores a strong reference to its members.
6. Identify the bug in the following code:

@interface TTWaitController : UIViewController

@property (strong, nonatomic) UILabel *alert;

@end

@implementation TTWaitController

- (void)viewDidLoad
{
CGRect frame = CGRectMake(20, 200, 200, 20);
self.alert = [[UILabel alloc] initWithFrame:frame];
self.alert.text = @"Please wait 10 seconds...";
self.alert.textColor = [UIColor whiteColor];
[self.view addSubview:self.alert];

NSOperationQueue *waitQueue = [[NSOperationQueue alloc] init];


[waitQueue addOperationWithBlock:^{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
self.alert.text = @"Thanks!";
}];
}

@end

@implementation TTAppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[TTWaitController alloc] init];
[self.window makeKeyAndVisible];
return YES;
}
How could you fix this issue?

When the above code dispatches work using NSOperationQueue’s method addOperationWithBlock,
there is no guarantee that the block being enqueued will be executed on the main thread. Notice that the
content of the UILabel is being updated within the body of the block. UI updates that are not executed on
the main thread can lead to undefined behavior. This code might appear to be working correctly for a long
time before anything goes wrong, but UI updates should always happen on the main thread.

The easiest way to fix the potential issue is to change the body of the block so that the update is
re-enqueued using the main thread’s queue as follows:

[waitQueue addOperationWithBlock:^{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
self.alert.text = @"Thanks!";
}];
}];

7. What’s the difference between an “app ID” and a “bundle ID” and what is each used for?
An App ID is a two-part string used to identify one or more apps from a single development team. The
string consists of a Team ID and a bundle ID search string, with a period (.) separating the two parts. The
Team ID is supplied by Apple and is unique to a specific development team, while the bundle ID search
string is supplied by teh developer to match either the bundle ID of a single app or a set of bundle IDs for
a group of apps.

Because most people think of the App ID as a string, they think it is interchangeable with Bundle ID. It
appears this way because once the App ID is created in the Member Center, you only ever use the App
ID Prefix which matches the Bundle ID of the Application Bundle.

The bundle ID uniquely defines each App. It is specified in Xcode. A single Xcode project can have
multiple Targets and therefore output multiple apps. A common use case for this is an app that has both
lite/free and pro/full versions or is branded multiple ways.

8. What are “strong” and “weak” references? Why are they important and how can they be used to help
control memory management and avoid memory leaks?
By default, any variable that points to another object does so with what is referred to as a “strong”
reference. A retain cycle occurs when two or more objects have reciprocal strong references (i.e., strong
references to each other). Any such objects will never be destroyed by ARC (iOS’ Automatic Reference
Counting). Even if every other object in the application releases ownership of these objects, these objects
(and, in turn, any objects that reference them) will continue to exist by virtue of those mutual strong
references. This therefore results in a memory leak.

Reciprocal strong references between objects should therefore be avoided to the extent possible.
However, when they are necessary, a way to avoid this type of memory leak is to employ weak
references. Declaring one of the two references as weak will break the retain cycle and thereby avoid the
memory leak.

To decide which of the two references should be weak, think of the objects in the retain cycle as being in
a parent-child relationship. In this relationship, the parent should maintain a strong reference (i.e.,
ownership of) its child, but the child should not maintain maintain a strong reference (i.e., ownership of) its
parent.

For example, if you have Employer and Employee objects, which reference one another, you would most
likely want to maintain a strong reference from the Employer to the Employee object, but have a weak
reference from the Employee to thr Employer.

9. Describe managed object context and the functionality that it provides.

A managed object context (represented by an instance of NSManagedObjectContext) is basically a


temporary “scratch pad” in an application for a (presumably) related collection of objects. These objects
collectively represent an internally consistent view of one or more persistent stores. A single managed
object instance exists in one and only one context, but multiple copies of an object can exist in different
contexts.

You can think of a managed object context as an intelligent scratch pad. When you fetch objects from a
persistent store, you bring temporary copies onto the scratch pad where they form an object graph (or a
collection of object graphs). You can then modify those objects however you like. Unless you actually
save those changes, though, the persistent store remains unchanged.

Key functionality provided by a managed object context includes:

Life-cycle management. The context provides validation, inverse relationship handling, and undo/redo.
Through a context you can retrieve or “fetch” objects from a persistent store, make changes to those
objects, and then either discard the changes or commit them back to the persistent store. The context is
responsible for watching for changes in its objects and maintains an undo manager so you can have
finer-grained control over undo and redo. You can insert new objects and delete ones you have fetched,
and commit these modifications to the persistent store.
Notifications. A context posts notifications at various points which can optionally be monitored elsewhere
in your application.
Concurrency. Core Data uses thread (or serialized queue) confinement to protect managed objects and
managed object contexts. In OS X v10.7 and later and iOS v5.0 and later, when you create a context you
can specify the concurrency pattern with which you will use it using initWithConcurrencyType:.
For more information, see the iOS Developer Library Core Data Basics or the NSManagedObjectContext
reference.

10. Compare and contrast the different ways of achieving concurrency in OS X and iOS.

There are basically three ways of achieving concurrency in iOS:

threads
dispatch queues
operation queues

The disadvantage of threads is that they relegate the burden of creating a scalable solution to the
developer. You have to decide how many threads to create and adjust that number dynamically as
conditions change. Also, the application assumes most of the costs associated with creating and
maintaining the threads it uses.

OS X and iOS therefore prefer to take an asynchronous design approach to solving the concurrency
problem rather than relying on threads.

One of the technologies for starting tasks asynchronously is Grand Central Dispatch (GCD) that relegates
thread management down to the system level. All the developer has to do is define the tasks to be
executed and add them to the appropriate dispatch queue. GCD takes care of creating the needed
threads and scheduling tasks to run on those threads.

All dispatch queues are first-in, first-out (FIFO) data structures, so tasks are always started in the same
order that they are added.

An operation queue is the Cocoa equivalent of a concurrent dispatch queue and is implemented by the
NSOperationQueue class. Unlike dispatch queues, operation queues are not limited to executing tasks in
FIFO order and support the creation of complex execution-order graphs for your tasks.
11. Will the code below log “areEqual” or “areNotEqual”? Explain your answer.

NSString *firstUserName = @"nick";


NSString *secondUserName = @"nick";

if (firstUserName == secondUserName)
{
NSLog(@"areEqual");
}
else
{
NSLog(@"areNotEqual");
}

The code will output “areEqual”.


While one might think this is obvious, it’s not. Here’s why:
Comparing pointer values equates to checking if they point to the same object. Pointers will have the
same value if and only if they actually point to the exact same object (whereas pointers to different
objects will not have the same value, even if the objects they point to have the same value).
In the above code snippet, firstUserName and secondUserName are each pointers to string objects. One
could easily assume that they are pointing to different string objects, despite the fact that the objects that
they point to both have the same value. However, the iOS compiler optimizes references to string objects
that have the same value (i.e., it reuses them rather than allocating identical string objects redundantly),
so both pointers are in fact pointing to same address and the condition therefore evaluates to true.

12. List and explain the different types of iOS Application States.

The iOS application states are as follows:

Not running state: The app has not been launched or was running but was terminated by the system.
Inactive state: The app is running in the foreground but is currently not receiving events. (It may be
executing other code though.) An app usually stays in this state only briefly as it transitions to a different
state. The only time it stays inactive for any period of time is when the user locks the screen or the
system prompts the user to respond to some event (such as an incoming phone call or SMS message).
Active state: The app is running in the foreground and is receiving events. This is the normal mode for
foreground apps.
Background state: The app is in the background and executing code. Most apps enter this state briefly on
their way to being suspended. However, an app that requests extra execution time may remain in this
state for a period of time. In addition, an app being launched directly into the background enters this state
instead of the inactive state.
Suspended state: While suspended, an app remains in memory but does not execute any code. When a
low-memory condition occurs, the system may purge suspended apps without notice to make more space
for the foreground app.

13. Consider the two methods below:

application:willFinishLaunchingWithOptions
application:didFinishLaunchingWithOptions
What is the usage of these methods and what is difference between them?

Both methods are present in the AppDelegate.swift file. They are use to add functionality to the app when
the launching of app is going to take place.

The difference between these two methods are as follows:

application:willFinishLaunchingWithOptions—This method is your app’s first chance to execute code at


launch time.
application:didFinishLaunchingWithOptions—This method allows you to perform any final initialization
before your app is displayed to the user.

14. What are rendering options for JSONSerialization?

MutableContainers: Arrays and dictionaries are created as variable objects, not constants.
MutableLeaves: Leaf strings in the JSON object graph are created as instances of variable strings.
allowFragments: The parser should allow top-level objects that are not an instance of arrays or
dictionaries.

Question 1
On a UITableViewCell constructor:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
What is the reuseIdentifier used for?
The reuseIdentifier is used to indicate that a cell can be re-used in a UITableView. For example when the
cell looks the same, but has different content. The UITableView will maintain an internal cache of
UITableViewCell’s with the reuseIdentifier and allow them to be re-used when
dequeueReusableCellWithIdentifier: is called. By re-using table cell’s the scroll performance of the
tableview is better because new views do not need to be created.

Question 2
Explain the difference between atomic and nonatomic synthesized properties?
Atomic and non-atomic refers to whether the setters/getters for a property will atomically read and write
values to the property. When the atomic keyword is used on a property, any access to it will be
“synchronized”. Therefore a call to the getter will be guaranteed to return a valid value, however this does
come with a small performance penalty. Hence in some situations nonatomic is used to provide faster
access to a property, but there is a chance of a race condition causing the property to be nil under rare
circumstances (when a value is being set from another thread and the old value was released from
memory but the new value hasn’t yet been fully assigned to the location in memory for the property).

Question 3
Explain the difference between copy and retain?
Retaining an object means the retain count increases by one. This means the instance of the object will
be kept in memory until it’s retain count drops to zero. The property will store a reference to this instance
and will share the same instance with anyone else who retained it too. Copy means the object will be
cloned with duplicate values. It is not shared with any one else.

Want to ace your technical interview? Schedule a ​Technical Interview Practice Session with an expert
now!

Question 4
What is method swizzling in Objective C and why would you use it?
Method swizzling allows the implementation of an existing selector to be switched at runtime for a
different implementation in a classes dispatch table. Swizzling allows you to write code that can be
executed before and/or after the original method. For example perhaps to track the time method
execution took, or to insert log statements
#import "UIViewController+Log.h"
@implementation UIViewController (Log)
+ (void)load {
static dispatch_once_t once_token;
dispatch_once(&once_token, ^{
SEL viewWillAppearSelector = @selector(viewDidAppear:);
SEL viewWillAppearLoggerSelector = @selector(log_viewDidAppear:);
Method originalMethod = class_getInstanceMethod(self, viewWillAppearSelector);
Method extendedMethod = class_getInstanceMethod(self, viewWillAppearLoggerSelector);
method_exchangeImplementations(originalMethod, extendedMethod);
});
}
- (void) log_viewDidAppear:(BOOL)animated {
[self log_viewDidAppear:animated];
NSLog(@"viewDidAppear executed for %@", [self class]);
}
@end

Question 5
What’s the difference between not-running, inactive, active, background and suspended execution
states?
● Not running: The app has not been launched or was running but was terminated by the system.
● Inactive: The app is running in the foreground but is currently not receiving events. (It may be
executing other code though.) An app usually stays in this state only briefly as it transitions to a
different state.
● Active: The app is running in the foreground and is receiving events. This is the normal mode for
foreground apps.
● Background: The app is in the background and executing code. Most apps enter this state briefly
on their way to being suspended. However, an app that requests extra execution time may remain
in this state for a period of time. In addition, an app being launched directly into the background
enters this state instead of the inactive state.
● Suspended: The app is in the background but is not executing code. The system moves apps to
this state automatically and does not notify them before doing so. While suspended, an app
remains in memory but does not execute any code. When a low-memory condition occurs, the
system may purge suspended apps without notice to make more space for the foreground app.

Question 6
What is a category and when is it used?
A category is a way of adding additional methods to a class without extending it. It is often used to add a
collection of related methods. A common use case is to add additional methods to built in classes in the
Cocoa frameworks. For example adding async download methods to the UIImage class.

Question 7
Can you spot the bug in the following code and suggest how to fix it:
@interface MyCustomController : UIViewController

@property (strong, nonatomic) UILabel *alert;


@end

@implementation MyCustomController

- (void)viewDidLoad {
CGRect frame = CGRectMake(100, 100, 100, 50);
self.alert = [[UILabel alloc] initWithFrame:frame];
self.alert.text = @"Please wait...";
[self.view addSubview:self.alert];
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
self.alert.text = @"Waiting over";
}
);
}

@end

All UI updates must be done on the main thread. In the code above the update to the alert text may or
may not happen on the main thread, since the global dispatch queue makes no guarantees . Therefore
the code should be modified to always run the UI update on the main thread
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
dispatch_async(dispatch_get_main_queue(), ^{
self.alert.text = @"Waiting over";
});
});

Question 8
What is the difference between viewDidLoad and viewDidAppear?
Which should you use to load data from a remote server to display in the view?
viewDidLoad is called when the view is loaded, whether from a Xib file, storyboard or programmatically
created in loadView. viewDidAppear is called every time the view is presented on the device. Which to
use depends on the use case for your data. If the data is fairly static and not likely to change then it can
be loaded in viewDidLoad and cached. However if the data changes regularly then using viewDidAppear
to load it is better. In both situations, the data should be loaded asynchronously on a background thread
to avoid blocking the UI.

Question 9
What considerations do you need when writing a UITableViewController which shows images
downloaded from a remote server?
This is a very common task in iOS and a good answer here can cover a whole host of knowledge. The
important piece of information in the question is that the images are hosted remotely and they may take
time to download, therefore when it asks for “considerations”, you should be talking about:
● Only download the image when the cell is scrolled into view, i.e. when cellForRowAtIndexPath is
called.
● Downloading 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 we need to check if that cell is still in the view or
whether it has been re-used by another piece of data. If it’s been re-used then we should discard
the image, otherwise we need to switch back to the main thread to change the image on the cell.
Other good answers will go on to talk about offline caching of the images, using placeholder images while
the images are being downloaded.

Question 10
What is a protocol, and how do you define your own and when is it used?
A protocol is similar to an interface from Java. It defines a list of required and optional methods that a
class must/can implement if it adopts the protocol. Any class can implement a protocol and other classes
can then send messages to that class based on the protocol methods without it knowing the type of the
class.
@protocol MyCustomDataSource
- (NSUInteger)numberOfRecords;
- (NSDictionary *)recordAtIndex:(NSUInteger)index;
@optional
- (NSString *)titleForRecordAtIndex:(NSUInteger)index;
@end

A common use case is providing a DataSource for UITableView or UICollectionView.

Question 11
What is KVC and KVO? Give an example of using KVC to set a value.
KVC stands for Key-Value Coding. It's a mechanism by which an object's properties can be accessed
using string's at runtime rather than having to statically know the property names at development time.
KVO stands for Key-Value Observing and allows a controller or class to observe changes to a property
value.
Let's say there is a property name on a class:
@property (nonatomic, copy) NSString *name;

We can access it using KVC:


NSString *n = [object valueForKey:@"name"]

And we can modify it's value by sending it the message:


[object setValue:@"Mary" forKey:@"name"]

Question 12
What are blocks and how are they used?
Blocks are a way of defining a single task or unit of behavior without having to write an entire Objective-C
class. Under the covers Blocks are still Objective C objects. They are a language level feature that allow
programming techniques like lambdas and closures to be supported in Objective-C. Creating a block is
done using the ^ { }syntax:
myBlock = ^{
NSLog(@"This is a block");
}

It can be invoked like so:


myBlock();

It is essentially a function pointer which also has a signature that can be used to enforce type safety at
compile and runtime. For example you can pass a block with a specific signature to a method like so:
- (void)callMyBlock:(void (^)(void))callbackBlock;

If you wanted the block to be given some data you can change the signature to include them:
- (void)callMyBlock:(void (^)(double, double))block {
...
block(3.0, 2.0);
}

Question 13
What mechanisms does iOS provide to support multi-threading?
● NSThread creates a new low-level thread which can be started by calling the start method.
NSThread* myThread = [[NSThread alloc] initWithTarget:self
selector:@selector(myThreadMainMethod:)
object:nil];
[myThread start];

● NSOperationQueue allows a pool of threads to be created and used to execute NSOperations in


parallel. NSOperations can also be run on the main thread by asking NSOperationQueue for the
mainQueue.
NSOperationQueue* myQueue = [[NSOperationQueue alloc] init];
[myQueue addOperation:anOperation];
[myQueue addOperationWithBlock:^{
/* Do something. */
}];

● GCD or Grand Central Dispatch is a modern feature of Objective-C that provides a rich set of
methods and API's to use in order to support common multi-threading tasks. GCD provides a way
to queue tasks for dispatch on either the main thread, a concurrent queue (tasks are run in
parallel) or a serial queue (tasks are run in FIFO order).
dispatch_queue_t myQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0);
dispatch_async(myQueue, ^{
printf("Do some work here.\n");
});

Question 14
What is the Responder Chain?
When an event happens in a view, for example a touch event, the view will fire the event to a chain of
UIResponder objects associated with the UIView. The first UIResponder is the UIView itself, if it does not
handle the event then it continues up the chain to until UIResponder handles the event. The chain will
include UIViewControllers, parent UIViews and their associated UIViewControllers, if none of those
handle the event then the UIWindow is asked if it can handle it and finally if that doesn't handle the event
then the UIApplicationDelegate is asked.
If you get the opportunity to draw this one out, it's worth doing to impress the interviewer:
Question 15
What's the difference between using a delegate and notification?
Both are used for sending values and messages to interested parties. A delegate is for one-to-one
communication and is a pattern promoted by Apple. In delegation the class raising events will have a
property for the delegate and will typically expect it to implement some protocol. The delegating class can
then call the _delegate_s protocol methods.
Notification allows a class to broadcast events across the entire application to any interested parties. The
broadcasting class doesn't need to know anything about the listeners for this event, therefore notification
is very useful in helping to decouple components in an application.
[NSNotificationCenter defaultCenter]
postNotificationName:@"TestNotification"
object:self];

Question 16
What's your preference when writing UI's? Xib files, Storyboards or programmatic UIView?
There's no right or wrong answer to this, but it's great way of seeing if you understand the benefits and
challenges with each approach. Here's the common answers I hear:
● Storyboard's and Xib's are great for quickly producing UI's that match a design spec. They are
also really easy for product managers to visually see how far along a screen is.
● Storyboard's are also great at representing a flow through an application and allowing a high-level
visualization of an entire application.
● Storyboard's drawbacks are that in a team environment they are difficult to work on collaboratively
because they're a single file and merge's become difficult to manage.
● Storyboards and Xib files can also suffer from duplication and become difficult to update. For
example if all button's need to look identical and suddenly need a color change, then it can be a
long/difficult process to do this across storyboards and xibs.
● Programmatically constructing UIView's can be verbose and tedious, but it can allow for greater
control and also easier separation and sharing of code. They can also be more easily unit tested.
Most developers will propose a combination of all 3 where it makes sense to share code, then re-usable
UIViews or Xib files.

Question 17
How would you securely store private user data offline on a device? What other security best practices
should be taken?
Again there is no right answer to this, but it's a great way to see how much a person has dug into iOS
security. If you're interviewing with a bank I'd almost definitely expect someone to know something about
it, but all companies need to take security seriously, so here's the ideal list of topics I'd expect to hear in
an answer:
● If the data is extremely sensitive then it should never be stored offline on the device because all
devices are crackable.
● The keychain is one option for storing data securely. However it's encryption is based on the pin
code of the device. User's are not forced to set a pin, so in some situations the data may not even
be encrypted. In addition the users pin code may be easily hacked.
● A better solution is to use something like ​SQLCipher which is a fully encrypted SQLite database.
The encryption key can be enforced by the application and separate from the user's pin code.
Other security best practices are:
● Only communicate with remote servers over SSL/HTTPS.
● If possible implement certificate pinning in the application to prevent man-in-the-middle attacks on
public WiFi.
● Clear sensitive data out of memory by overwriting it.
● Ensure all validation of data being submitted is also run on the server side.

Question 18
What is MVC and how is it implemented in iOS?
What are some pitfalls you've experienced with it? Are there any alternatives to MVC?
MVC stands for Model, View, Controller. It is a design pattern that defines how to separate out logic when
implementing user interfaces. In iOS, Apple provides UIView as a base class for all _View_s,
UIViewController is provided to support the Controller which can listen to events in a View and update the
View when data changes. The Model represents data in an application and can be implemented using
any NSObject, including data collections like NSArray and NSDictionary.
Some of the pitfalls that people hit are bloated UIViewController and not separating out code into classes
beyond the MVC format. I'd highly recommend reading up on some solutions to this:
● https://www.objc.io/issues/1-view-controllers/lighter-view-controllers/
● https://speakerdeck.com/trianglecocoa/unburdened-viewcontrollers-by-jay-thrash
● https://programmers.stackexchange.com/questions/177668/how-to-avoid-big-and-clumsy-uitablevi
ewcontroller-on-ios
In terms of alternatives, this is pretty open ended. The most common alternative is MVVM using
ReactiveCocoa, but others include VIPER and using Functional Reactive code.

Question 19
A product manager in your company reports that the application is crashing. What do you do?
This is a great question in any programming language and is really designed to see how you problem
solve. You're not given much information, but some interviews will slip you more details of the issue as
you go along. Start simple:
● get the exact steps to reproduce it.
● find out the device, iOS version.
● do they have the latest version?
● get device logs if possible.
Once you can reproduce it or have more information then start using tooling. Let's say it crashes because
of a memory leak, I'd expect to see someone suggest using Instruments leak tool. A really impressive
candidate would start talking about writing a unit test that reproduces the issue and debugging through it.
Other variations of this question include slow UI or the application freezing. Again the idea is to see how
you problem solve, what tools do you know about that would help and do you know how to use them
correctly.

Question 20
What is AutoLayout? What does it mean when a constraint is "broken" by iOS?
AutoLayout is way of laying out UIViews using a set of constraints that specify the location and size
based relative to other views or based on explicit values. AutoLayout makes it easier to design screens
that resize and layout out their components better based on the size and orientation of a screen.
_Constraint_s include:
● setting the horizontal/vertical distance between 2 views
● setting the height/width to be a ratio relative to a different view
● a width/height/spacing can be an explicit static value
Sometimes constraints conflict with each other. For example imagine a UIView which has 2 height
constraints: one says make the UIView 200px high, and the second says make the height twice the height
of a button. If the iOS runtime can not satisfy both of these constraints then it has to pick only one. The
other is then reported as being "broken" by iOS.
1. What was the latest version of iOS you worked with? What do you like about it and why?
The purpose of this question is to inquire if the interviewee actually keeps up with the latest development
from Apple.
Expected answer: he/she tells you what the latest version of the system is and what he/she has worked
with lately. And tells you about one of the new features of the system that he/she is excited about (i.e. I
love new multitasking on iPad because it’s going to make user experience way better and opens up a lot
of opportunities for us developers to build new cool things, etc.).

2. Have you worked with Swift? What do you like about it? What you don’t like?
This question will give you a sense of several things:
● is he cautious with using something as unstable as Swift. For example 2.0/2.1 releases broke a lot
of things/libraries and a senior developer would think twice about using Swift on a production
application. Because a lot of libraries and frameworks necessary for production ready iOS
development either do not exist yet in pure Swift or do not work anymore with newer versions of
the language (as of today - 11/11/15).
● whether the developer is bold enough to play with the cutting edge stuff
● what’s his long terms plans and expectations (is he optimistic or pessimistic or somewhere in
between)
Expected answer: be cautious, use Swift along with Objective-C for now and move to pure Swift down the
road in several years when it and the ecosystem of libraries around it matures enough.

3. How memory management is handled on iOS?


This question will give you an idea of how long the person was working with iOS, whether she/he’s a
newcomer who’s worked only with ​ARC or he/she’s worked with manual retain count (​MRC​) and has a
deeper knowledge/experience with memory management on iOS.
Expected answer: it is great if interviewee knows MRC but it is not necessary. More important that he/she
understands ​strong, weak, assign​, etc. directives on properties and can confidently tell you what those
directives imply and how it’s handled with blocks.

4. What do you know about singletons? Where would you use one and where you wouldn't?
This is a typical objective oriented programming question. In case of iOS you can get a feel of how the
interviewee is using it in his/her apps. You’ll be able to weed out those people who came from Java/PHP
and such and use it as a “global” store or something similar.
Expected answer: singletons should be avoided and used only for objects that need to be shared
throughout your application for same reason. It should be used carefully, instantiated lazily, if it’s possible,
and passed into other objects as a dependency using Inversion of Control and Dependency Injection
principles.
Red flag: is when the interviewee talks about global variables and stores.

5. Could you explain what is the difference between Delegate and KVO?
With this question you are assessing their knowledge of different types of messaging patterns used in
iOS. Senior developer should’ve used both of those many times in his/her applications.
Expected answer: Both are ways to have relationships between objects. ​Delegation is a one to one
relationship where one object implements a delegate protocol and another uses it and sends messages
to assuming that those methods are implemented since the receiver promised to comply to the protocol.
KVO is many-to-many relationship where one object could broadcast a message and one or multiple
other objects can listen to it and react.

6. How do you usually persist data on iOS?


This will tell you if they just played with rudimentary ways to store data locally on iOS like
NSUserDefaults, Plists, disk file storage, etc. or if they have used more advanced storages like Core Data
and Realm. Ideally they should know when it is appropriate to use all of the above persistence tools.
Expected answer: A senior developer should at least be able to tell you when it is appropriate to use
NSUserDefaults, Core Data, and disk file storage. ****Core Data is what you’re expecting them to explain
you the most. Other possible options are Realm and similar third party (non-Apple) solutions but make
sure they know why they would want to use them instead of Core Data. With Core Data they should be
able to explain how it works and how it’s different from SQLite (i.e. it’s an object graph rather than a
relational database, etc.).

7. How do you typically do networking?


Networking is a vital part of almost any application these days. In fact the majority of them is useless
without an internet connection. Any decent iOS developer should know how to initiate various networking
requests (GET, POST, PUT, DELETE, etc.) using Apple’s frameworks or third party tools such as
[AFNetworking](https://github.com/AFNetworking/AFNetworking).
Expected answer: Interviewee should be able to explain how to do not just basic networking but more
advanced things like HTTP headers and token handling. But in general look for developers who use
either [AFNetworking](https://github.com/AFNetworking/AFNetworking) or
[Alamofire](https://github.com/Alamofire/Alamofire) or similar. The reason is these libraries are used very
extensively by iOS community and are utilized in many other tools. Senior developer should be able to
utilize that instead of reinventing a wheel.

8. How do you serialize data on iOS (JSON from the web or local app data to Core Data and other
storages) ?
Data serialization is an important task for every iOS application. JSON is defacto standard of data
serialization on the web and every developer should know how to effectively work with it without spending
a lot of time writing boilerplate code. Same applies to data serialization for local storage. It can be
handled in multiple ways but a good developer should at least be aware of the challenges with these
tasks.
Expected answer: This is a tricky question. A naive developer would say that he/she parses JSON data
using Apple’s [NSJSONSerialization]
(https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSJSONSerialization_Clas
s/) and then takes the resulting dictionary and assigns the data from each key to respective properties on
his/her model object. This is not what you expect a senior developer to tell you. Senior developer should
be aware of the issues that could arise with data serialization such as data validation and conversion. A
good answer would be clear understanding that in general there are two types of data serialization: JSON
to domain model, and domain model to persistence. Utilization of pods like ​Mantle or ​ObjectMapper or a
similar library/pod is expected.

9. What design patterns do you know and use on iOS?


This could be a very simple or a very complicated answer. Every iOS developer should know about MVC
but if you’re looking for a senior developer than he/she should have a lot of patterns and best practices on
how to organize code under his belt.
Expected answer: at least ​MVVM​. This is the holy grail that saves iOS developers from ​Massive View
Controllers​. Senior developer should be able to explain you what MVVM is, why it’s better than MVC, and
should be able to tell you what other patterns he/she uses along with MVVM (Inversion of Control,
Dependency Injection, etc.).
Red flags: if interviewee tells you that he uses only MVC because Apple said so and he/she never tried
MVVM than that person is definitely not a senior iOS developer.

10. What is Autolayout?


Autolayout is one of the technologies on iOS that helps us build scalable UI that can be used on many
devices of different shape and size. This is a must know for any iOS developer especially for a senior
one.
Expected answer: do not expect proficiency with this technology but the interviewee should be able to tell
you when and how he/she would use it and what benefits it gives them (i.e. scalable adjustable
declarative UI).

11. How do you handle async tasks?


Asynchronous programming is a vital part of any iOS application. Networking, local storage, and other
heavy computation tasks should be handled in the background to avoid blocking UI and having users wait
or system kill your application.
Expected answer: answers to this questions may vary from ​NSOperations and ​GCD to Promises and
RAC. A good developer knows multiple ways to execute async operations and knows when they are
necessary (i.e. with networking, local persistence, etc. see above). From a senior developer though we
expect a more higher and broader level of tools they use such as ​ReactiveCocoa​ and ​PromiseKit​.

12. How do you manage dependencies?


Dependencies management is a vital but daunting task. It was very difficult and error prone to do before
but these days we have several tools to help us out with it. Every iOS dev should know how to handle
dependencies and collaborate with other teammates.
Expected answer: CocoaPods and/or Carthage.
Red flags: if the say that they don’t use any dependency manager and just copy files to the project folder.
Also a red flag if the use git submodules (it leads to project configuration issues and inconsistencies
between local setups for different developers on the team).

13. How do you debug and profile things on iOS?


No one writes perfect code and debugging and profiling is one of the tools that we use to figure out the
right technical solution. On iOS we have all the typical “manual” debugging tools such as NSLog/print
functions to output things in console. But Apple also provides us with more advanced variety of tools and
instruments to help with identifying where problems lie.
Expected answer: every iOS developer should be able to explain how he/she would use breakpoints and
logs to get the runtime data but from a senior developer you should expect to hear things about
Instruments​ and ​Crash Logs​.

14. Do you code review?


Code reviews is one of the most effective development methodologies. It helps understand the problem
better, share knowledge, share techniques, catch bugs, share ownership of the codebase, etc. This style
of development is not for everyone but every development should be able to do that effectively.
Expected answer: senior developer should be more or less proficient in this type of code collaboration.
Again, this is not for everyone (depends on personality, compatibility and other factors), but that is a skill
that should show you if the candidate is able to work with other people and communicate his thoughts
and ideas clearly to another teammate.

15. Do you test your code? What do you do to make your code testable?
This is embarrassing but we admit that we don’t do testing as much as we should. We know we really
really should do it more. We are talking about Unit Testing and Integration Testing specifically here.
Expected answer: there is only one right answer here: either they do it or they wish they would. In general
iOS community isn’t as big on testing as say Ruby community. Partially it is due to inherited lack of testing
culture and partially due to lack of good tools for testing but things seems to be improving on that front.
The Questions
Now for the time you’ve been waiting for – the questions!
Our technical interviews last one hour and I have a sheet of 75 questions from which I will draw randomly
at first. Then, depending upon what I learn about the candidate, I will tailor my choice of questions
somewhat. For example, if I suspect the candidate has a weak spot, I will hone in on that area.
I do have favorites and go-to questions that will have to be retired after the publication of this article.
Expect my first question to now be: Have you read this article? :]
When answering questions, try to keep your answer brief and explain your thought process when it is
beneficial. The interviewer isn’t asking you these questions because they don’t know the answers – they
want to see if you know what you are talking about.
Note that I’m just going to list the questions here, not the answers. That’s for you to figure out, if you don’t
know already – learning is half the fun! Feel free to share the answers in the forums once you’ve figured
them out.
Without further ado, here are some sample questions for the technical interview:
● Explain method swizzling. When you would use it? — I like this question because it’s deep
language. Most people will never need to use swizzling. The developer’s answer to this question
also shows me how much restraint s/he has when implementing complex code. An answer of “I
swizzle everything” is much scarier than someone saying they have never worked with it.
● Take three objects: a grandparent, parent and child. The grandparent retains the parent, the
parent retains the child and the child retains the parent. The grandparent releases the parent.
Explain what happens. — Even with ARC, I like to ask a lot of memory-related questions, as it
shows that someone has been around for a while and has core knowledge about how things work.
● What happens when you invoke a method on a nil pointer? — Basic Objective-C handling is
important and it’s shocking how many times I have heard wrong answers to questions like this.
● Give two separate and independent reasons why retainCount should never be used in shipping
code. — This question has two benefits: to make sure someone isn’t using retainCount and to see
if they understand why they shouldn’t use it.
● Explain your process for tracing and fixing a memory leak. — This dives into the applicant’s
knowledge of memory, instruments and the debugging process. Sometimes I hear things like
“start commenting out code until it is fixed,” which is slightly terrifying.
● Explain how an autorelease pool works at the runtime level. — These types of questions go
beyond the basics a programmer will learn from a couple of books and investigates his or her
knowledge of how things actually work.
● When dealing with property declarations, what is the difference between atomic and non-atomic?
— Once again, it is shocking how many people don’t know the answer to this question. Many just
declare properties a certain way because it’s what they’ve seen others do. Questions like these
expose those issues.
● In C, how would you reverse a string as quickly as possible? — I don’t like to dive too deeply into
computer science, but this question lets me know how someone thinks about performance as well
as about his or her background in C. I have also been known to dig into big O notation.
● Which is faster: to iterate through an NSArray or an NSSet? — Another deep dive. Sometimes just
because a class solves a problem doesn’t mean it’s the one you should be using.
● Explain how code signing works. — A lot of applicants have no idea how code signing works and
then complain because they are having code signing issues.
● What is posing in Objective-C? — Posing is a little-used feature of Objective-C. Like the swizzling
question, this gives me an indication of how deep someone has dived into the language.
● List six instruments that are part of the standard. — This question gives me a general idea of how
much time someone has spent in instruments. Hint: It should be at least 10% of your coding time,
if not more.
● What are the differences between copy and retain? — Memory questions reveal a lot about a
developer’s knowledge, especially since many people are leaning on ARC these days.
● What is the difference between frames and bounds? — I don’t ask a lot of GUI-type questions and
I probably should ask more, but this one gives me an idea of how much layout work a developer
has done.
● What happens when the following code executes? Ball *ball = [[[[Ball alloc] init] autorelease]
autorelease]; — Another memory question. The answer I am looking for here is not just that it will
crash, which it will – I want to know why and when.
● List the five iOS app states. — Almost no one gets this question right. Normally I have to give an
example, such as background state, for them to know what I am talking about.
● Do you think this interview was a good representation of your skills as a developer? — Some
people test well and some don’t. I like to give people the option to explain their results a little.
Confidence is important and the answer to this question can reveal a lot about a person’s
confidence.
Many of these questions can be followed up with a “Why does that happen?” or “Explain your thinking in
getting there.” The point of a technical interview is to determine just how much of a language or platform a
candidate knows – and as you’ve seen, not just the breadth of knowledge, but the depth also.
The technical interview doesn’t do much to reveal what a person is like as a developer – it simply
determines if someone is worthy of moving forward in the process. The best academic developers who
may knock the technical interview out of the park may completely fall to pieces in the practical coding
interview, but someone who bombs the technical interview won’t be a good candidate for the position. If
they can’t discuss topics such as these with their coworkers, then they won’t be able to contribute to the
growth of the team.

What do you use to layout your views correctly on iOS?


Knowing your options for laying out things on the screen is crucial when you need to solve different UI
challenges on iOS. This question helps gauge your knowledge about how you put and align views on the
screen. Answering this question you should at least mention CGRect Frames and AutoLayout but it would
be great to mention other options such a ComponentKit and other Flexboxand React implementation on
iOS.
Expected answer: go to options for laying out views on the screen are good old CGRect Frames and
AutoLayout. Frames along with autoresizing 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 devices of various size and form.
Since iOS 6 we have AutoLayout which is the go-to solution these days and is preferred by Apple.
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.
There are other options for laying out views such as ​ComponentKit​, ​LayoutKit​that more or less inspired
by React. These alternatives are good in certain scenarios when, for example, you need to build a highly
dynamic and fast table views and collection views. AutoLayout is not always perfect for that and knowing
that there are other options is always good.
Red flag: not mentioning at least AutoLayout and the fact that Frames are notoriously hard to get right is
definitely going to be a red flag for your interviewer. These days no one in their sane mind would do
CGRect frame calculations unless it is absolutely necessary (for example when you do some crazy
drawings).
What are CGRect Frames? When and where would you use it?
This question is asked to learn if you have a background in building UI "the hard way" with using view
position and size calculation. Frames were used previously before AutoLayout to position UI elements on
the screen but these days there are other options you have to solve that problem. The interviewer is
trying to figure out how advanced you are in and how well you know a lower level of UI rendering.
Expected answer: The simples way to position views on the screen is to give them explicit and specific
coordinates and sizes with CGRects. CGRect is a struct that represents a rectangle that a view is placed
at. It has origin with x and yvalues, and size with width and height values. They represent upper-left
corner where the view starts to draw itself and width and height of that view respectively. Frames are
used to explicitly position views on the screen and have the most flexibility in terms of what and how you
position on the screen. But the disadvantage is that you have to take care of everything yourself (with
great power comes great responsibility, you know). Meaning even though you're in full control of how your
UI is drawn on the screen you will have to take care of all the edge cases and different screen size and
resolutions.
A better option these days is AutoLayout. It helps you with layout positioning through constraints and sets
specific frames for views for you. It makes your views scalable and adaptive to different screen sizes and
resolutions.
Red flag: AutoLayout is de facto the standard of doing layouts these days, Frames are considered to be
an outdated concept that is very error prone. Saying that frames are perfectly fine for laying out views
would raise a red flag because most likely your interviewer would think that you don't know how to build
adaptive and responsive UI.
What is AutoLayout? When and where would you use it?
This is very common UI related question on any interview. Virtually no interview will go without it.
AutoLayout is one of the fundamental technologies that Apple pushed on for some time and now it is de
facto the standard. Your interviewer either is expecting a very short and brief answer to get an
understanding if you're versed in the topic or they'll drill down and ask you all the details about it. Be
prepared for both.
Expected answer: 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. AutoLayout came as an evolution of previously used Frames and auto-resizing masks.
Apple created it to support various screen resolutions and sizes of iOS devices.
In the nutshell using AutoLayout instead of setting view frames you'll create NSLayoutConstraint objects
either in code or use nibs or storyboards. NSLayoutConstraints describe how views relate to each other
so that at runtime UIKit can decide what CGRect frames specifically to set for each view. It will adjust to
different screen sizes or orientation changes based on the "rules" you defined using constraints.
The main things you'll be using working with AutoLayout are: NSLayoutRelation, constant, and priority.
● NSLayoutRelation defines the nature of a constraint between two UI items/views. It can be
lessThanOrEqual, equal, or greaterThanOrEqual.
● constant defines constraint value. It usually defines things like the distance between two views, or
width of an item, or margin, etc.
● priority defines how high of a priority a given constraint should take. Constraints with higher
priority number take precedence over other. Priority typically is used to resolve conflicting
constraints. For example, when there could be an absence of content we may want to align
elements differently, in that scenario we'd create several constraints with different priority.
Bonus points: working with Apple's API for constraints in code is sometimes problematic and difficult.
There are several different open source libraries out there that can help with it such as ​Masonry and
PureLayout​ that dramatically simplify the process.
Red flag: AutoLayout is de facto the standard today for developing UI on iOS, disregarding it or trying to
prove that Frames approach is better most likely is going to raise a red flag. There are alternatives of
course but most likely your interviewer expects you to be very familiar with the technology since it's such
a vital part of any iOS application.

*Q: How would you create your own custom view?


A:By Subclassing the UIView class.

*Q: What is App Bundle?


A:When you build your iOS app, Xcode packages it as a bundle. A bundle is a directory in the file system
that groups related resources together in one place. An iOS app bundle contains the app executable file
and supporting resource files such as app icons, image files, and localized content.
*Q: Whats fast enumeration?
A:Fast enumeration is a language feature that allows you to enumerate over the contents of a collection.
(Your code will also run faster because the internal implementation reduces message send overhead and
increases pipelining potential.)

*Q: Whats a struct?


A:A struct is a special C data type that encapsulates other pieces of data into a single cohesive unit. Like
an object, but built into C.

*Q: Whats the difference between NSArray and NSMutableArray?


A:NSArrayʼs contents can not be modified once itʼs been created whereas a NSMutableArray can be
modified as needed, i.e items can be added/removed from it.

*Q: Explain retain counts.

A:Retain counts are the way in which memory is managed in Objective-C. When you create an object, it
has a retain count of 1. When you send an object a retain message, its retain count is incremented by 1.
When you send an object a release message, its retain count is decremented by 1. When you send an
object a autorelease message, its retain count is decremented by 1 at some stage in the future. If an
objectʼs retain count is reduced to 0, it is deallocated.
This will explain how the memory management is done in iOS

*Q: Whats the difference between frame and bounds?


A:The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the
superview it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) and
size (width,height) relative to its own coordinate system (0,0).

*Q: Is a delegate retained?


A:No, the delegate is never retained! Ever!

*Q:Outline the class hierarchy for a UIButton until NSObject.


A:UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder,
UIResponder inherits from the root class NSObject.

*Q: What are the App states. Explain them?


A:
● Not running State: The app has not been launched or was running but was terminated by the
system.
● Inactive state: The app is running in the foreground but is currently not receiving events. (It may
be executing other code though.) An app usually stays in this state only briefly as it transitions to a
different state. The only time it stays inactive for any period of time is when the user locks the
screen or the system prompts the user to respond to some event, such as an incoming phone call
or SMS message.
● Active state: The app is running in the foreground and is receiving events. This is the normal
mode for foreground apps.
● Background state: The app is in the background and executing code. Most apps enter this state
briefly on their way to being suspended. However, an app that requests extra execution time may
remain in this state for a period of time. In addition, an app being launched directly into the
background enters this state instead of the inactive state. For information about how to execute
code while in the background, see “Background Execution and Multitasking.”
● Suspended state:The app is in the background but is not executing code. The system moves apps
to this state automatically and does not notify them before doing so. While suspended, an app
remains in memory but does not execute any code. When a low-memory condition occurs, the
system may purge suspended apps without notice to make more space for the foreground app.

*Q: Explain how the push notification works.


A:
*Q: Explain the steps involved in submitting the App to App-Store.
A: Apple provides the tools you need to develop, test, and submit your iOS app to the App Store. To run
an app on a device, the device needs to be provisioned for development, and later provisioned for testing.
You also need to provide information about your app that the App Store displays to customers and upload
screenshots. Then you submit the app to Apple for approval. After the app is approved, you set a date the
app should appear in the App Store as well as its price. Finally, you use Apple’s tools to monitor the sales
of the app, customer reviews, and crash reports. Then you repeat the entire process again to submit
updates to your app.
Ref: [block]2[/block]

*Q: Why do we need to use @Synthesize?


A: We can use generated code like nonatomic, atmoic, retain without writing any lines of code. We also
have getter and setter methods. To use this, you have 2 other ways: @synthesize or @dynamic:
@synthesize, compiler will generate the getter and setter automatically for you, @dynamic: you have to
write them yourself.@property is really good for memory management, for example: retain.How can you
do retain without @property?
if (_variable != object)
{
[_variable release];
_variable = nil;
_variable = [object retain];
}
How can you use it with @property?self.variable = object; When we are calling the above line, we actually
call the setter like [self setVariable:object] and then the generated setter will do its job.

*Q: Multitasking support is available from which version?


A:
iOS 4.0.
*Q: How many bytes we can send to apple push notification server?
A:
256bytes.

*Q: Can you just explain about memory management in iOS?


A:
Refer:​ iOS Memory Management

*Q: What is code signing?


A:
Signing an application allows the system to identify who signed the application and to verify that the
application has not been modified since it was signed. Signing is a requirement for submitting to the App
Store (both for iOS and Mac apps). OS X and iOS verify the signature of applications downloaded from
the App Store to ensure that they they do not run applications with invalid signatures. This lets users trust
that the application was signed by an Apple source and hasn’t been modified since it was signed.

Development Basics
Q1. Where can you test Apple iPhone apps if you don’t have the device?
A. iOS Simulator can be used to test mobile applications. Xcode tool that comes along with iOS SDK
includes Xcode IDE as well as the iOS Simulator. Xcode also includes all required tools and frameworks
for building iOS apps. However, it is strongly recommended to test the app on the real device before
publishing it.
Q2. Does iOS support multitasking?
A. iOS 4 and above supports multi-tasking and allows apps to remain in the background until they are
launched again or until they are terminated.
Q3. Which JSON framework is supported by iOS?
A. SBJson framework is supported by iOS. It is a JSON parser and generator for Objective-C. SBJson
provides flexible APIs and additional control that makes JSON handling easier.
Q4. What are the tools required to develop iOS applications?
A. iOS development requires Intel-based Macintosh computer and iOS SDK.
Q5. Name the framework that is used to construct application’s user interface for iOS.
A. The UIKit framework is used to develop application’s user interface for iOS. UIKit framework provides
event handling, drawing model, windows, views, and controls specifically designed for a touch screen
interface.
Q6. Name the application thread from where UIKit classes should be used?
A. UIKit classes should be used only from an application’s main thread. Note: The derived classes of
UIResponder and the classes which manipulate application’s user interface should be used from
application’s main thread.
Q7. Which API is used to write test scripts that help in exercising the application's user interface
elements?
A. UI Automation API is used to automate test procedures. Tests scripts are written in JavaScript to the
UI Automation API. This in turn simulates user interaction with the application and returns log information
to the host computer.
App States and Multitasking
Q8. Why an app on iOS device behaves differently when running in foreground than in background?
A. An application behaves differently when running in foreground than in background because of the
limitation of resources on iOS devices.
Q9. How can an operating system improve battery life while running an app?
A. An app is notified whenever the operating system moves the apps between foreground and
background. The operating system improves battery life while it bounds what your app can do in the
background. This also improves the user experience with foreground app.
Q10. Which framework delivers event to custom object when app is in foreground?
A. The UIKit infrastructure takes care of delivering events to custom objects. As an app developer, you
have to override methods in the appropriate objects to process those events.
App States
Q11. When an app is said to be in not running state?
A. An app is said to be in 'not running' state when:
- it is not launched.
- it gets terminated by the system during running.
Q12. Assume that your app is running in the foreground but is currently not receiving events. In which
sate it would be in?
A. An app will be in InActive state if it is running in the foreground but is currently not receiving events. An
app stays in InActive state only briefly as it transitions to a different state.
Q13. Give example scenarios when an application goes into InActive state?
A. An app can get into InActive state when the user locks the screen or the system prompts the user to
respond to some event e.g. SMS message, incoming call etc.
Q14. When an app is said to be in active state?
A. An app is said to be in active state when it is running in foreground and is receiving events.
Q15. Name the app sate which it reaches briefly on its way to being suspended.
A. An app enters background state briefly on its way to being suspended.
Q16. Assume that an app is not in foreground but is still executing code. In which state will it be in?
A. Background state.
Q17. An app is loaded into memory but is not executing any code. In which state will it be in?
A. An app is said to be in suspended state when it is still in memory but is not executing any code.
Q18. Assume that system is running low on memory. What can system do for suspended apps?
A. In case system is running low on memory, the system may purge suspended apps without notice.
Q19. How can you respond to state transitions on your app?
A. On state transitions can be responded to state changes in an appropriate way by calling corresponding
methods on app's delegate object.
For example:
applicationDidBecomeActive method can be used to prepare to run as the foreground app.
applicationDidEnterBackground method can be used to execute some code when app is running in the
background and may be suspended at any time.
applicationWillEnterForeground method can be used to execute some code when your app is moving out
of the background
applicationWillTerminate method is called when your app is being terminated.
Q20. List down app's state transitions when it gets launched.
A. Before the launch of an app, it is said to be in not running state.
When an app is launched, it moves to the active or background state, after transitioning briefly through
the inactive state.
Q21. Who calls the main function of you app during the app launch cycle?
A. During app launching, the system creates a main thread for the app and calls the app’s main function
on that main thread. The Xcode project's default main function hands over control to the UIKit framework,
which takes care of initializing the app before it is run.
Core App Objects
Q22. What is the use of controller object UIApplication?
A. Controller object UIApplication is used without subclassing to manage the application event loop.
It coordinates other high-level app behaviors.
It works along with the app delegate object which contains app-level logic.
Q23. Which object is create by UIApplicationMain function at app launch time?
A. The app delegate object is created by UIApplicationMain function at app launch time. The app
delegate object's main job is to handle state transitions within the app.
Q24. How is the app delegate is declared by Xcode project templates?
A. App delegate is declared as a subclass of UIResponder by Xcode project templates.
Q25. What happens if IApplication object does not handle an event?
A. In such case the event will be dispatched to your app delegate for processing.
Q26. Which app specific objects store the app's content?
A. Data model objects are app specific objects and store app’s content. Apps can also use document
objects to manage some or all of their data model objects.
Q27. Are document objects required for an application? What does they offer?
A. Document objects are not required but are very useful in grouping data that belongs in a single file or
file package.

Q28. Which object manage the presentation of app's content on the screen?
A. View controller objects takes care of the presentation of app's content on the screen. A view controller
is used to manage a single view along with the collection of subviews. It makes its views visible by
installing them in the app’s window.
Q29. Which is the super class of all view controller objects?
A. UIViewController class. The functionality for loading views, presenting them, rotating them in response
to device rotations, and several other standard system behaviors are provided by UIViewController class.
Q30. What is the purpose of UIWindow object?
A. The presentation of one or more views on a screen is coordinated by UIWindow object.
Q31. How do you change the content of your app in order to change the views displayed in the
corresponding window?
A. To change the content of your app, you use a view controller to change the views displayed in the
corresponding window. Remember, window itself is never replaced.
Q32. Define view object.
A. Views along with controls are used to provide visual representation of the app content. View is an
object that draws content in a designated rectangular area and it responds to events within that area.
Q33. You wish to define your custom view. Which class will be subclassed?
A. Custom views can be defined by subclassing UIView.
Q34. Apart from incorporating views and controls, what else an app can incorporate?
A. Apart from incorporating views and controls, an app can also incorporate Core Animation layers into its
view and control hierarchies.
Q35. What are layer objects and what do they represent?
A. Layer objects are data objects which represent visual content. Layer objects are used by views to
render their content. Custom layer objects can also be added to the interface to implement complex
animations and other types of sophisticated visual effects.
Q Name four important data types found in Objective-C.
Four data types that you’ll definitely want your developer to be aware of are as follows:
NSString: Represents a string.
CGfloat: Represents a floating point value.
NSInteger: Represents an integer.
BOOL: Represents a boolean.

Q How proficient are you in Objective-C and Swift? Can you briefly describe their differences?
When Swift was first launched in 2014, it was aptly described as “Objective-C without the C.” By dropping
the legacy conventions that come with a language built on C, Swift is faster, safer, easier to read, easier
to maintain, and designed specifically for the modern world of consumer-facing apps. One of the most
immediately visible differences is the fact that Objective-C lacks formal support for namespaces, which
forces Objective-C code to use two- or three-letter prefixes to differentiate itself. Instead of simple names
like “String,” “Dictionary,” and “Array,” Objective-C must use oddities like “NSString,” “NSDictionary,” and
“NSArray.”
Another major advantage is that Swift avoids exposing pointers and other “unsafe” accessors when
referring to object instances. That said, Objective-C has been around since 1983, and there is a mountain
of Objective-C code and resources available to the iOS developer. The best iOS developers tend to be
pretty well versed in both, with an understanding that Swift is the future of iOS development.

Q What are UI elements and some common ways you can add them to your app?
Buttons, text fields, images, labels, and any other elements that are visible within the application are
called UI elements. These elements may be interactive and comprise the user interface (hence the term
“UI”) of an application. In iOS development, UI elements can be quickly added through Xcode’s interface
builder, or coded from scratch and laid out using NSLayoutConstraints and Auto Layout. Alternatively,
each element can also be positioned at exact coordinates using the UIView
“(id)initWithFrame:(CGRect)frame” method.

Q Explain the purpose of the reuseIdentifier in the UITableViewCell constructor:


(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
The reuseIdentifier tells UITableView which cells may be reused within the table, effectively grouping
together rows in a UITableView that differ only in content but have similar layouts. This improves scroll
performance by alleviating the need to create new views while scrolling. Instead the cell is reused
whenever dequeueReusableCellWithIdentifier: is called.

Q What are some common execution states in iOS?


The common execution states are as follows:
Not Running: The app is completely switched off, no code is being executed.
Inactive: The app is running in the foreground without receiving any events.
Active: The app is running in the foreground and receiving events.
Background: The app is executing code in the background.
Suspended: The app is in the background but is not executing any code.

Q What is the purpose of managed object context (NSManagedObjectContext) in Objective-C and how
does it work?
Managed object context exists for three reasons: life-cycle management, notifications, and concurrency. It
allows the developer to fetch an object from a persistent store and make the necessary modifications
before deciding whether to discard or commit these changes back to the persistent store. The managed
object context tracks these changes and allows the developer to undo and redo changes.

Q Determine the value of “x” in the Swift code below. Explain your answer.

var a1 = [1, 2, 3, 4, 5]
var a2 = a1
a2.append(6)
var x = a1.count

In Swift, arrays are implemented as structs, making them value types rather than reference types (i.e.,
classes). When a value type is assigned to a variable as an argument to a function or method, a copy is
created and assigned or passed. As a result, the value of “x” or the count of array “a1” remains equal to 5
while the count of array “a2” is equal to 6, appending the integer “6” onto a copy of the array “a1.” The
arrays appear in the box below.

a1 = [1, 2, 3, 4, 5]
a2 = [1, 2, 3, 4, 5, 6]

Q Find the bug in the Objective-C code below. Explain your answer.

@interface HelloWorldController : UIViewController

@property (strong, nonatomic) UILabel *alert;

@end

@implementation HelloWorldController

- (void)viewDidLoad {
CGRect frame = CGRectMake(150, 150, 150, 50);
self.alert = [[UILabel alloc] initWithFrame:frame];
self.alert.text = @"Hello...";
[self.view addSubview:self.alert];
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
self.alert.text = @"World";
}
);
}

@end

All UI updates must be performed in the main thread. The global dispatch queue does not guarantee that
the alert text will be displayed on the UI. As a best practice, it is necessary to specify any updates to the
UI occur on the main thread, as in the fixed code below:

dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
dispatch_async(dispatch_get_main_queue(), ^{
self.alert.text = @"World";
});
});

Q Explain the difference between raw and associated values in Swift.


This question tests the developer’s understanding of enumeration in Swift. Enumeration provides a
type-safe method of working with a group of related values. Raw values are compile time-set values
directly assigned to every case within an enumeration, as in the example detailed below:

enum Alphabet: Int {


case A = 1
case B
case C
}

In the above example code, case “A” was explicitly assigned a raw value integer of 1, while cases “B” and
“C” were implicitly assigned raw value integers of 2 and 3, respectively. Associated values allow you to
store values of other types alongside case values, as demonstrated below:

enum Alphabet: Int {


case A(Int)
case B
case C(String)
}

Q You’ve just been alerted that your new app is prone to crashing. What do you do?
This classic interview question is designed to see how well your prospective programmer can solve
problems. What you’re looking for is a general methodology for isolating a bug, and their ability to
troubleshoot issues like sudden crashes or freezing. In general, when something goes wrong within an
app, a standard approach might look something like this:
○ Determine the iOS version and make or model of the device.
○ Gather enough information to reproduce the issue.
○ Acquire device logs, if possible.
○ Once you have an idea as to the nature of the issue, acquire tooling or create a unit test
and begin debugging.
A great answer would include all of the above, with specific examples of debugging tools like Buglife or
ViewMonitor, and a firm grasp of software debugging theory—knowledge on what to do with compile time
errors, run-time errors, and logical errors. The one answer you don’t want to hear is the haphazard
approach—visually scanning through hundreds of lines of code until the error is found. When it comes to
debugging software, a methodical approach is must.

2. Explain Fast Enumeration.


Fast enumeration is a iOS Programming Language feature that enables you to enumerate over the
contents of a collection. It will also make your code execute your code faster due to internal
implementation which gets reduced message sending overheads and increased pipelining potential.
3. Explain ARC.
ARC represents Automatic Reference Counting. It is a Compiler level feature that simplifies the process
of managing the lifetimes of Objects in Objective – C. ARC evaluates the Lifetime requirements of
Objects and automatically includes appropriate Methods to be called during Compilation.
4. Explain Mutable and Immutable Types in Objective C Programming Language.
Mutable Types means you can modify the Contents later when you feel the need. However, when an
Object is marked as Immutable, it implies that the data cannot be modified later after it has been
initialized. Therefore, the stored values are Constant here.
Example:
NSString, NSArray values cannot be altered after initialization.
5. What is Garbage Collection?
Garbage Collection is a Memory Management feature. It manages the allocation and release of the
memory to your applications. When the garbage collector performs a collection, it checks for objects in
the managed heap that are not executed by the applications.
6. Explain xib.
.xib is a file extension that is associated with Interface Builder files. It is a graphics software that is used to
test, develop and design the User Interfaces of different software products. Such extension files also
contains development time format files that includes interface files created with the interface builder
softwares.
7. Which Programming Languages are used for iOS Development?
The languages used for iOS development are as follows:
1. Objective-C
2. .NET
3. C
4. HTML5
5. JavaScript
6. Swift
8. Explain App ID.
It is primarily used to identify one or more apps from a Unique Development team. It consists of a string
divided into two parts. The string includes a Team ID and a Bundle ID Search String with a separator as a
period. The Team ID is allocated by Apple and is different for every development team. A Bundle ID
Search String is supplied by the App Developer.
9. Explain usage of struct.
struct is a Datatype in C Programming Language that enables encapsulation of other pieces of data into a
single cohesive unit. It is similar to an object but in C Programming Language.
10. What is an Object?
Objects are essentially the variables that are of Class types. Objects are basic Run-Time entities in an
Object oriented system. They may represent a place, a bank account or a person.
11. Enlist the methods to achieve Concurrency in iOS.
The following listed are the methods to achieve concurrency functionality in iOS:
1. Threads
2. Dispatch Queues
3. Operation Queues
12. What is Cocoa?
Cocoa is an Application Development Environment for Mac OS X Operating System and iOS. It includes
Compilations of a Runtime System, Object-Oriented Software Libraries and an Integrated Development
Environment.
13. What is a Framework?
It is basically a conceptual structure or a scheme with an intension to support the expansion of the
structure into something useful. A Framework is a layered structure indicating what kind of programs can
or should be built and how they would interact. Frameworks includes actual programs that mentions
programming interfaces and programming tools for working with the frameworks.
14. Explain keywords alloc and new.
The alloc keyword is used to create a New Memory Location in the System. However, it does not initialize
it. In case of New keyword, it also helps to create a New Memory Location in the system. However, it can
initialize the Contents unlike the alloc keyword.
15. What are Selectors in Objective-C?
A Selector in Objective C can be used to refer the name of a method when it is used in a Source-Code
message to an Object. It also refers to the unique identifiers that can replace the Name when the Source
Code is being Compiled. All the methods that have the same name have the same selector.
16. Enlist Frameworks for Cocoa.
The Frameworks developed for Cocoa are listed as follows:
1. Foundation
2. Application Kit
17. What is Bundle ID?
The Bundle ID uniquely defines every iOS Application. It is specified in Xcode. It is a Search String which
is supplied by the Application Developer to match either the Bundle ID of a Single Application or a Set of
Bundle IDs for a Group of Applications.
18. What is a Class?
The entire set of data of an object can be made a user-defined data type using a class. Objects are
basically variables of Class type. Once a Class has been defined, it is possible to create multiple Objects
of its type. A Class is a collection of Objects of similar type.
19. Explain the difference between Inheritance and Category.
Category enables to add methods only. It does not allow the inclusion of Data Members unlike
Inheritance where both the Data and Methods can be added. Category includes Complete Application in
its Scope whereas Inheritance’s scope is only within that particular File.
20. Explain App Bundle.
During iOS application development, Xcode packages it as a bundle. A Bundle is a file directory that
combines related resources together in one place. It contains the Application Executable File and
supports Resource Files such as Localized Content, Image Files and Application Icons.
21. What is Swift?
Swift is a programming language for development of applications for OS X, iOS, watchOS, and tvOS.
These applications are developed using C and Objective-C. It does not have the constraints of C
Programming. It has features for easier development and provides more flexibility.
22. What is a Protocol in Objective-C Programming Language?
A Protocol is used to define a list of required optional methods that a class needs to implement. If a class
adopts a protocol, it must implement all the needed methods in the protocols it adopts. It is identical to an
Interface in Java and also to a purely Virtual Class in C++. Cocoa uses protocols to support interprocess
communication through Objective-C messages.
23. Explain Formal Protocols.
Formal Protocols enables defining an Interface for a Set of Methods without any implementation. It is
useful with DistributedObjects as they allow defining a protocol for communication between objects.
24. What is Polymorphism?
It enables a methods to exhibit different behaviours under different instances. The task of creating a
Function or an Operator behave differently in different instances is known as Operator Overloading which
is an implementation of Polymorphism.
25. Differentiate between Release and Pool Drain.
The release keyword is used to free a memory location in the system which is not being utilized. The
drain keyword is used to release the NSAutoreleasePool.
26. What is a Collection?
A Collection is a Foundation Framework Class that is used to Manage and Store the group of Objects.
The primary role of a Collection is to store Objects in the form of either a Set, a Dictionary or an Array.
27. Explain the significance of AutoRelease.
AutoRelease: When you send an Object AutoRelease message, it gets added to the Local AutoRelease
Pool. When the AutoRelease Pool gets destroyed, the Object will receive a Release
message. The Garbage Collection functionality will destroy the Object if it has the RetainCount as Zero.
28. What is the First Responder and Responder Chain.
A Responder Chain is a hierarchy of Objects that can respond to the events received. The first object in
the ResponderChain is called the First Responder.
29. Explain Web Services?
The Web Services are the Application Components which enables communication using Open Protocols.
These Web Services are Self – Describing and Self – Contained. Web Services can be found out by
using UDDI. The base for development of Web Services functionality is Extensible Markup Language
(XML).
30. Explain the difference between Cocoa and Cocoa Touch?
Cocoa is an Application Framework that enables development of Applications in Mac OS X Environment.
It is basically a combination of two Frameworks i.e., Appkit Framework and Foundation Framework.
Cocoa Touch is an Application Framework for iPod Touch. Iphone and iPad. It includes the Foundation
Framework and UIKit Framework.
31. Explain plist.
Plist represents Property Lists. It is a key-value store for the Application to Save and Retrieve persistent
data values. This is specifically used for iPhone development. It is basically and XML File.
32. Explain IPA.
IPA represents iOS App Store Package. It has an .ipa extension which represents iPhone application
archive file that stores an iPhone application. Every file is compressed with a Binary for the ARM
architecture and can only be installed on an iPhone, ipad or an iPod Touch. It is mostly encrypted with
Apple’s FairPlay DRM Technology.
33. Which JSON Framework is supported by iOS?
SBJSON is the framework that is supported by iOS. It is a generator and a JSON Parser for Objective-C.
SBJSON provides flexible APIs and also makes JSON handling easier.
34. Explain Inheritance.
Inheritance is an Object Oriented Programming concept. It allows to develop a New Class that is reusable
and can extend the behaviour that is defined in another class.
35. How is it possible to improve Battery Life during execution of an Application?
An application is notified whenever the Operating System transfers the application between Background
and Foreground. It helps in extended battery life by determining the exact functionalities in the
background and thereby also helps in a better User Experience with the Foreground Application.
36. Does iOS supports Multi-Tasking functionality?
Multi-Tasking functionality is supported from iOS versions 4 and the later ones. Multi-Tasking is a feature
that enables applications to remain in the background until it is re-launched or terminated.
37. What is Xcode?
Xcode is a combination of Software Development Tools developed by Apple for developing applications.
It is an Integrated Development Environment (IDE). It is primarily used for development of iOS and OS X
applications.
38. Explain Layer Objects.
Layer Objects are Data Objects that represent the Visual Content. They are used to render the Content.
Layer Objects can be customized and these custom layer objects are used to implement Complex
Animations and other types of sophisticated Visual Effects.
39. What framework is used to construct application’s iOS User Interface?
The UIKit framework is the Framework that is used to develop application’s User Interface for iOS. UIKit
framework provides Views, Drawingg Model, Controls, Event Handling, Windows specifically designed for
a touch screen interface.
40. Explain Interfaces.
Interfaces enables defining features as small groups of closly related properties, methods, and events. It
defines the events, properties and methods that classes can implement.
41. Enlist Frameworks for Cocoa Touch.
The Frameworks developed for Cocoa Touch are listed as follows:
1. Foundation
2. UIKit
42. How can you declare a variable in Swift?
Var num = 42
43. What is the Maximum byte-size for a push notification to Apple Server?
The maximum memory size is 256 Bytes to send a push Notification to Apple Server.
So this was the list of some important IOS interview questions and answers. If you found any information
incorrect or missing in above list then please mention it by commenting below.
1.What is class?
Ans. In Objective-C, we define objects by defining their class. The class definition is a prototype for a kind
of object; it declare the instance variable that become part of every member of the class, and it defines a
set of methods that can be use by all objects in a class.

2.What is Object?Ans. As the name implies that object orient programme based around object. The
object associate data with particular operation that that affect or use data.

3.What is OOPS and explain oops concept?

An object-oriented approach to application development makes programs more intuitive to design, faster
to develop, more amenable to modification, and easier to understand.

The Objective-C language is a programming language designed to enable sophisticated object-oriented


programming. Objective-C is defined as a small but powerful set of extensions to the standard ANSI C
language. Its additions to C are mostly based on Smalltalk, one of the first object-oriented programming
languages.

There are 4 pillars of OOPS as follows:


● Abstraction
● Encapsulation
● Polymorphism
● Inheritance
4.What is Abstraction?

Ans. Abstraction is a mechanism of exposing only the interfaces and hiding the implementation details
from the user.
Abstraction is "To represent the essential feature without representing the back ground details".

5.What is Encapsulation?

Ans. Encapsulation is an Object Oriented Programming concept that binds together the data and
functions that manipulate the data, and that keeps both safe from outside interference and misuse. Data
encapsulation led to the important OOP concept of data hiding.

6.What is polymorphism?

Ans. Ability of base class pointer to access the child class methods at run time is called polymorphism.
There is 2 types of polymorphism in OOPS:
● Compile time / Static (Over loading)
● Run Time / Dynamic (Over riding)
7.What is Inheritance?

Ans. Inheritance is a way to reuse of existing code or code of existing objects.

8.What is object oriented relations (Composition,Aggregation,Association)?


● Composition: It gives us a ‘part-of’ relationship. Member Object can’t survive or exist outside the
enclosing or containing class.
● Aggregation: It gives a ‘has-a’ relationship. Member Object can’t survives or exist without the
enclosing class. It doesnot imply ownerShip,object can exist independently of each other.
● Association: It’s also a relation in which there is no OwnerShip or Container. Association is a
relationship between two objects.association defines multiplicity between objects.
Category :

Category allows you to add methods to an existing class without sub-classing it.For example we can
create category for NSObject that allow to add methods for NSObject class.(e.g. We can add our own
methods to NSString class.)
Unlike sub-classing, categories cant add instance variables.
Extension :
A class extension bears some similarity to a category, but it can only be added to a class for which you
have the source code at compile time (the class is compiled at the same time as the class extension).
Protocol :
Protocols are used to define methods that are to be implemented by other classes.For example we can
implement cellForRowatIndexPath method to ask for cell content to insert in tableview.This method is
defined in UITableViewDataSource protocol.

Declaration:
@protocol MyTestProtocol <NSObject>

@required
-(void)method1;
-(void)method1;

@optional
-(void)method1;

@end

Delegate :

Delegates are used when you want to call the built-in methods of a class.Here one object passes work to
another object.The object doing the work is the delegate of first object

10 important Questions for iOS developer:

1. Have you aware of Application submission process in AppStore?


2. How many apps have you published in the Apple App Store? What are the names of those apps.
3. Do you have any experience in new technology or specific feature in your app like
iAd,multithreading,accelerometer, location based services, in-app purchases, etc.
4. What is memory leak and how do you overcome this in your app.
5. What is code signing and how does it work for iOS apps?
6. Tell me about your testing process. What tools do you use for app testing, and how would I be
involved?
7. Do have any knowledge on Business applications ? Have you developed any revenue generating
apps, either through iAds or in-app purchases? Can you describe that process and what you
learned?
8. What are the tools you are using for memory management and Code review process?
9. What are the Designing patterns you have follwed to develop ios applications?
10. What are the UI design Guidelines you following to create simple and elegant Designs?

(http://way2ios.com/category/refernece/programming/objective-c/)
(https://github.com/MaximAbramchuck/awesome-interview-questions#ios)
(https://github.com/9magnets/iOS-Developer-and-Designer-Interview-Questions)
iOS Technologies Questions:
● Explain Handoff, and in general, how it allows iOS and Mac/web apps to communicate?
● What technologies/services are contained inside of iCloud?
● What is an iOS extension? Can you list a few examples of popular/common extensions?
● What is HealthKit?
● What is HomeKit?
● What is Apple Pay? Could you describe a way we could use it in our applications?
● Explain application sandboxing.
● What is VoiceOver? Explain some of the accessibility features included in iOS and how
developers can utilize them.
● How does application multitasking work on iOS?
● What features does Game Center offer for iOS games?
● What are iBeacons?
● What is Cocoa/Cocoa Touch?
● Explain in general, what Core Audio, Core Data, and Core Location are, and how they help iOS
apps.
● Describe the role of SpriteKit and SceneKit.
● What is Metal?
● What is the responder chain? How does it work?
● What are the different actions that buttons and other controls can respond to?
● What is the role of the application delegate?
● Explain NSUserDefaults. How would you serialize an array to disk?
● How would you store user's credentials?
● Explain Keychain Services.
● Why are caching and compression important on mobile devices?
● Explain ~/Documents, ~/Library, ~/tmp. What directory is ~ on iOS?
● How does AirPlay work? How would you use it (programmatically) to enhance the utility and
presentation of an app?
● Give a brief overview of what sensors, IO and communication methods (Wifi, telephony, etc) are
available on iOS. How can you make use of these?
● What are the hardware performance differences among the iPad 2 / iPad mini 1-3, iPad Retina,
iPad Air 2, iPhone 5, 5s, 6, and 6+. What do these constraints mean for performance intensive
apps?
[⬆]​ Coding Questions:
● What does Cocoa Touch include and not include?
● Why do Cocoa Touch classes start with two capital letters?
● What is Swift, what is Objective-C and how do they relate and compare?
● Explain why optionals are useful in Swift.
● Explain NSError and how it works (or doesn't) in Swift.
● How does instancetype work and how is it useful?
● When is let appropriate in Swift? var?
● Why and where is the map function useful.
● How do you track down bugs? What are your tools of choice?
● You found a bug in Cocoa. What do you do?
● There is a regression in a new distributed version of our app causing crashes. How do you
mitigate it? How will you prevent new bugs from reaching customers?
● How are Objective-C classes implemented? Describe how the Objective-C runtime is
implemented.
● What security does iOS offer to protect customers and privileged information?
● Our app downloads data and displays it immediately. In accordance with MVC where is the best
place to perform the download?
● How does MVC influence the design of a codebase?
● What methods are part of the controller life-cycle? The view life-cycle?
● What design patterns does iOS make use of? What design patterns do you use in your codebase?
● What queues does iOS provide and how can you best utilize them?
● Give a brief description of how UIScrollView is implemented. How does it operate with gesture
recognizers, multiple touches and the run loops?
● What API would you add or improve on iOS?
[⬆]​ Interface Questions:
● What is the screen resolution of the iPhone 5, 6, 6+. and iPad Air 2?
● What units is the resolution measured in?
● Explain the purpose of Interface Builder, what is a NIB file?
● What image filetype should iOS UI assets be saved in?
● Describe some differences between a Storyboard and a standard NIB file.
● What is the device status bar? How tall is it in points? Is it opaque or transparent? What does it do
during a phone call or navigation?
● What is a navigation bar? Can you show me an Apple app on your phone that uses a navigation
bar?
● What is a tab bar? What is a toolbar? Compare and contrast them.
● What is a table view? What is a collection view?
● Describe when a popover is most appropriate.
● What is a split-view controller?
● What sort of content would be appropriate to place in a picker view?
● When are a label, text field and text view appropriate?
● What does a segmented control do?
● What is a modal view?
● What kind of notifications does iOS offer?
[⬆]​ Design Questions:
● What is an iOS app icon? Describe it as best as you can.
● What is the smallest size an app icon could be? What's the largest size it could be?
● Can an app icon contain any transparency?
● How does a Newsstand icon differ from a regular app icon?
● Explain a launch image.
● Describe the purpose of Auto Layout, and in general, how it works.
● Describe the role of animation in design of software.
● Describe the role of interactivity and feedback when designing software.
● What are some differences to take into account when building an iPhone app vs an iPad app?
● Describe the importance and role of prototyping when working on an app design.
[⬆]​ App Store Questions:
● How do In-App Purchases work? What can be purchased with IAP?
● Have you ever submitted an app to the App Store? Can you explain the general process?
● What is iTunes Connect?
● What is a provisioning profile?
● What is an App ID?
● What are the differences between Development and Production iOS signing certificates?
● How is TestFlight used? How were UUIDs used in ad-hoc app distribution?
● When do purchase receipts need to be verified?
● What is required to display iAds?
[⬆]​ Fun Questions:
● What's a cool thing you've coded recently? What's something you've built that you're proud of?
● What are some things you like about the developer tools you use?
● Who are some of your favorite independent Mac or iOS developers?
● Do you have any pet projects? What kind?
● What would you change about Xcode?
● What is your favorite iOS API?
● Do you have a pet or favorite bug report?
● What are your favorite ways to investigate a new technology?
● Why are dictionaries called dictionaries? Why not hash tables or hash maps?
[⬆]​ Other References:
● iOS Dev Weekly
● Accidental Tech Podcast
● Debug Podcast
● The Talk Show
● NSHipster
● KZBootstrap
● WWDC Videos
● ASCII WWDC
● Pttrns
● Ray Wenderlich Tutorials
● iOS Version Stats
● iOS Human Interface Guidelines
● Black Pixel blog post on hiring iOS and Mac engineers
● Macoscope guide to a technical interview

You might also like