ios questions Flashcards

1
Q

How could you set up Live Rendering?

A

The attribute @IBDesignable lets Interface Builder perform live updates on a particular view. IBDesignable requires Init frame to be defined as well in UIView class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between Synchronous & Asynchronous task?

A

Synchronous: waits until the task have completed

Asynchronous: completes a task in the background and can notify you when complete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain Compilation Conditions

A

Compilation Conditions to use if DEBUG … endif structure to include or disable given block of code ve separate targets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is made up of NSError object?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Enum or Enumerations?

A

Enum is a type that basically contains a group of related values in the same umbrella but case-less enum won’t allow us to create an instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the bounding box?

A

The smallest rectangle completely containing all points in a path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is @synthesize in Objective-C?

A

synthesize generates getter and setter methods for your property.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is @dynamic in Objective-C?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why do we use synchronized?

A

synchronized guarantees that only one thread can be executing that code in the block at any given time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the difference strong, weaks, read only and copy?

A

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 ( non-strong reference ), 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.

Every time used on var
Every time used on an optional type
Automatically changes itself to nil

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Dynamic Dispatch?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What’s Code Coverage?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s Completion Handler?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to Prioritize Usability in Design ?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What’s the difference between the frame and the bounds?

A

The bounds of a 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 a UIView is the rectangle, expressed as a location (x,y) and size (width, height) relative to the superview it is contained within.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is Responder Chain ?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is Regular expressions?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is Operator Overloading?

A

Operator overloading allows us to change how existing operators behave with types that both already exist. Operators are those little symbols like +, *, and /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is TVMLKit?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is Platform limitations of tvOS?

A

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 onboard storage.
tvOS app bundle cannot exceed 4 GB.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is Functions?

A

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
Q

What is ABI?

A

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. ABI stability will come with Swift 5.0

24
Q

Why is design pattern very important ?

A

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
Q

What is Singleton Pattern ?

A

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
Q

What is Facade Design Pattern?

A

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
Q

What is Decorator Design Pattern?

A

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
Q

What is Adapter Pattern?

A

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
Q

What is Observer Pattern?

A

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
Q

30- What is Memento Pattern?

A

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
Q

Explain MVC

A

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
Q

Explain MVVM

A

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
Q

How many different annotations available in Objective-C ?

A

_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
Q

What is JSON/PLIST limits ?

A

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
Q

What is SQLite limits ?

A

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
Q

What is Realm benefits ?

A

An open-source database framework.

Implemented from scratch.

Zero copy object store.

Fast.

37
Q

How many are there APIs for battery-efficient location tracking ?

A

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
Q

What is the Swift main advantage ?

A

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
Q

Explain generics in Swift ?

A

Generics create code that does not get specific about underlying data types. Don’t catch this article. Generics allow us to know what type it is going to contain. Generics also provides optimization for our code.

40
Q

Explain lazy in Swift ?

A

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 lazy properties come very handy to developers

41
Q

Explain what is defer ?

A

defer keyword which provides a block of code that will be executed in the case when execution is leaving the current scope

42
Q

How to pass a variable as a reference ?

A

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
Q

How to pass data between view controllers?

A

There are 3 ways to pass data between view controllers.
Segue, in prepareForSegue method (Forward)
Delegate (Backward)
Setting variable directly (Forward)

44
Q

What is Concurrency ?

A

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

45
Q

Grand Central Dispatch (GCD)

A

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
Q

Readers-Writers

A

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
Q

NSOperation

A

NSOperation adds a little extra overhead compared to GCD, but we can add dependency among various operations and re-use, cancel or suspend them.

48
Q

NSOperationQueue

A

It allows a pool of threads to be created and used to execute NSOperations in parallel. Operation queues aren’t part of GCD.

49
Q

NSBlockOperation

A

allows you to create an NSOperation from one or more closures. NSBlockOperations can have multiple blocks, that run concurrently.

50
Q

KVC

A

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.

51
Q

KVO

A

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.

52
Q

Please explain Swift’s pattern matching techniques

A

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.

53
Q

Explain Guard statement

A

There are three big benefits to guard statement.

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 second benefit is providing an early exit out of the function using break or using return.

The last benefit, guard statement is another way to safely unwrap optionals.