The Fundamentals Flashcards

1
Q

what is let and var in Swift?

A

let is used to declare constant and var is used to declare variable

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

What is the difference between structs and classes?

A

Classes reference type. Structs are value types.

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

How is memory management handled in iOS?

A

Swift uses automatic reference counting (ARC). ARC keeps track of strong references to instances of classes and increases or decreases their reference counting on assign and unassign.

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

What is protocol in Swift?

A
Declarations of what a type that adopts them should implement. 
@objc - class only
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an extension and when is it used?

A
A way to extend the existing functionality of a class or type.
drawback - globally applied
be aware of - name conflicts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are closures/blocks?

A

Declare and capture a piece of executable code that will be launched at a later time

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

What are the components of MVC for a typical iOS app?

A
  1. UIView are the views
  2. UIViewControllers are the Controllers
  3. any data objects, NSManagedObject subclasses are models
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Singletons?

A

A class that returns only one-and-the-same instance no matter how many times you request it

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

What are 2 major disadvantages to using singletons?

A
  1. global state and object lifecycle

2. dependency injection

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

What is Delegate pattern?

A

A variation of the Observer pattern where only one object can observe events coming from another object

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