Sie sind auf Seite 1von 10

1.

What is Memory Management and


ARC?
A program needs to allocate and deallocate memory as needed.
Swift does that automatically. Swift does not use a garbage
collector which is a common tool. ARC is Automatic Reference
Counting introduced for Obj-C.

Everything is automatically managed, but you need to know


ARC to avoid memory leaks.

Retain Cycles?

Retain cycles happens when a reference is pointing to another


reference so it will never be removed from the heap.

This mostly happens in classes and closures. Closures live in


memory, so when you use Self which is a reference you need to
make sure that you solve the retain cycle.

Weak, unowned, strong?

Unless you specify otherwise, all Swift properties are strong,


which means they will not be removed from RAM until
whatever owns them is removed from RAM.
Weak on the other hand is there when you want to say “I want
to be able to reference this variable, but I don’t mind if it goes
away, so I don’t want to own it.” This might seem strange: after
all, where’s the point in having a reference to a variable that
might not be there?

Unowned means “don’t mind this one, I will make sure it is


removed from memory.”

2. What is MVC & Other Design


Patterns You Use?
Model-View-Controller is a design pattern based on three
job categories: model, view or controller.

Model: Models are responsible for storing data and making it


available to other objects.

View: Views are the visual elements of an application. What


you see on screen.

Controllers: Controllers perform the logic necessary connect


your views and models. They process events.
You may use different kinds of design patterns when you are
developing your apps, but here are the most common ones.

Singleton: The Singleton design pattern ensures that only one


instance exists for a given class

Singleton Plus: you can create another object. Doesn’t force


you to use the shared one.

Facade: The Facade design pattern provides a single interface


to a complex subsystem. Let’s say you have NetworkManager
class where you make HTTP requests and you have JSON
response. With using Facade, you can keep your
NetworkManager just focused on networking.

Decorator: The Decorator pattern dynamically adds behaviors


and responsibilities to an object without modifying its code.

Adapter: 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.

Observer: 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).
3. What is the difference between
value types and reference types?
The major difference is that value types are copied when they
are passed around, whereas reference types share a single copy
of the referenced information.

4. What is an optional in Swift and


what problem do optionals solve?
An optional is used to let a variable of any type represent the
lack of value. An optional variable can hold either a value or
nil any time.

5. What are the main differences


between Structures and Classes?
Classes support inheritance, structures don’t. Classes are
reference types, structures are value types.

6. What are the various ways to


unwrap an optional? How do they
rate in terms of safety?
forced unwrapping ! operator  —  unsafe

implicitly unwrapped variable declaration  —  unsafe in


many cases

optional binding  —  safe

optional chaining  —  safe

nil coalescing operator  —  safe

guard statement  —  safe

optional pattern  —  safe

7. What is auto-layout?
Auto layout dynamically calculates the size and position of all
the views in your view hierarchy based on constraints placed on
those views.

8. What are Higher Order Functions


in Swift?
Sort: Sorting arrays
Map: Transform array contents

Filter: Filter array based upon some criteria

Reduce: Reduce the values in collection to a single value

9. What is Lazy Loading?


Lazy loading means the calculation of the property’s value
will not occur until the first time it is needed.

10. What is CoreData?


Core Data is a framework for managing an object graph. An
object graph is nothing more than a collection of interconnected
objects. The framework excels at managing complex object
graphs.

Bonus: Differences between


Concurrent and Serial Queues?
Concurrent: multiple at the same time

Serial: first come first served, first in first out, ordered


1. What is Cocoa and Cocoa Touch?
Cocoa Cocoa Touch

1. Application development environments for 1. Application development environments for


OS X iOS

2. Includes the Foundation and AppKit 2. Includes Foundation and UIKit


frameworks frameworks

3. Used to refer any class/object which is 3. Used to refer the application development
based on the Objective-C runtime & inherits using any programmatic interface
from the root class
More about it here.

2. Which JSON framework is supported by iOS?


● iOS supports SBJson framework.
● SBJson is a JSON parser and generator for Objective-C.
● It provides flexible APIs and additional control, making JSON handling easier.

3. What is the difference between atomic and nonatomic


properties? Which is the default for synthesized properties?
Properties specified as atomic always return a fully initialized object. This also happens to be
the default state for synthesized properties. But, 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 give you better performance
than atomic.

4. Differentiate ‘app ID’ from ‘bundle ID’. Explain why they


are used.
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 the developer to match
either the bundle ID of a single app or a set of bundle IDs for a group of apps.
The bundle ID defines each App and is specified in Xcode. A single Xcode project can have
multiple targets and therefore output multiple apps. A common use case is an app that has
both lite/free and pro/full versions or is branded multiple ways.

5. Which are the ways of achieving concurrency in iOS?


The three ways to achieve concurrency in iOS are:
● Threads
● Dispatch queues
● Operation queues

6. Explain the different types of iOS Application States.


The different iOS application states are:
● Not running state: when the app has not been launched or was running but was
terminated by the system.
● Inactive state: when the app is running in the foreground but is currently not receiving
events. An app stays in this state briefly as it transitions to a different state. The only
time it stays inactive is when the user locks the screen or the system prompts the
user to respond to some event such as a phone call or SMS message.
● Active state: when the app is running in the foreground and is receiving events. This
is the normal mode for foreground apps.
● Background state: when 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 can remain in this state for some time. Also, an app
being launched directly into the background enters this state instead of the inactive
state.
● Suspended state: A suspended 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.

7. Which is the framework that is used to construct


application’s user interface for iOS?
The UIKit framework is used to develop application’s user interface for iOS. It provides event
handling, drawing model, windows, views, and controls specifically designed for a touch
screen interface.

8. Which is the application thread from where UIKit classes


should be used?
UIKit classes should be used only from an application’s main thread.

9. Which API would you use to write test scripts to exercise


the application’s UI elements?
UI Automation API is used to automate test procedures. JavaScript test scripts that are written
to the UI Automation API simulate user interaction with the application and return log
information to the host computer.

10. When would you say that an app is not in a running state?
An app is said to be in ‘not running’ state in the following cases:
– When it is not launched.
– When it gets terminated by the system during running.
11. When is an app said to be in active state?
An app is said to be in active state when it is running in the foreground and is receiving events.
12. Which are the app’s state transitions when it is launched?
An app is said to be in not running state before its launch.
After briefly transitioning through the inactive state, it moves to the active or background state
when it is launched.

13. Which is the state an app reaches briefly on its way to


being suspended?
An app enters background state briefly on its way to being suspended.

14. What is Swift and what is Objective-C?


Objective-C is the primary programming language you use to write software for OS X and iOS.
It’s a superset of the C programming language and provides object-oriented capabilities and
a dynamic runtime. Objective-C inherits the syntax, primitive types, and flow control
statements of C and adds syntax for defining classes and methods. It also adds language-
level support for object graph management and object literals while providing dynamic typing
and binding, deferring many responsibilities until runtime.
Swift is a new programming language for iOS, OS X, watchOS, and tvOS apps that builds on
the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe
programming patterns and adds modern features to make programming easier, more flexible,
and more fun. Swift feels familiar to Objective-C developers and is friendly to new
programmers.
Source: Apple developer library

15. What is SpriteKit and what is SceneKit?


SpriteKit is a framework for easy development of animated 2D objects.
SceneKit is a framework inherited from OS X that assists with 3D graphics rendering.
SpriteKit, SceneKit, and Metal are expected to power a new generation of mobile games that
redefine what iOS devices’ powerful GPUs can offer.

16. What are iBeacons?


iBeacon.com defines iBeacon as Apple’s technology standard which allows Mobile Apps to
listen for signals from beacons in the physical world and react accordingly. iBeacon technology
allows Mobile Apps to understand their position on a micro-local scale, and deliver hyper-
contextual content to users based on location. The underlying communication technology is
Bluetooth Low Energy.

17. What is autorealease pool?


Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool.
When the pool is drained, it simply sends -release to all the objects in the pool.
Autorelease pools are a convenience that allows you to defer sending -release until “later”.
That “later” can happen in several places, but the most common in Cocoa GUI apps is at the
end of the current run loop cycle.
18. Differentiate between ‘assign’ and ‘retain’ keyword.
Retain -specifies that retain should be invoked on the object upon assignment. It takes
ownership of an object.
Assign – specifies that the setter uses simple assignment. It is used on attribute of scalar type
like float,int.
19. 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.
20. Outline the class hierarchy for a UIButton until NSObject.
UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from
UIResponder, UIResponder inherits from the root class NSObject.

Das könnte Ihnen auch gefallen