iOS Flashcards

1
Q

What are the 4 Obj-C Data Types?

A
  • Bool
  • NSInteger
  • NSUInteger
  • NSString
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name 6 key features of Swift

A
  • Type Safety
  • Simplicity
  • Readability
  • Multiplatform support
  • Open source
  • Obj-C Compatible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the pieces that make up an NSError object?

A
  1. Error Domain
  2. Error Code
  3. Application specific user info
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain what an Enum is

A

Variable with user defined values that can be used in a type safe way with switches and conditionals

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

What does the lazy keyword mean?

A

The property defined as lazy will not be computed until its called

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

What is a generic is swift?

A

A function or class that that does not infer type to allow for reusability

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

What does KVC mean and do?

A

Key value constant. Allows access of properties via string instead of property names

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

What does KVO mean and do?

A

Key Value Object: allows other objects to observe changes to the specified object

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

What are the 3 steps of Test Driven Development?

A

Fail
Pass
Refactor

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

What does a completion handler do?

A

Calls a function when a task completes

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

What are the 4 types of queues?

A

Dispatch
Serial Dispatch
Concurrent Dispatch
Main Dispatch

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

What does a dispatch queue do?

A

A dispatch queue is responsible for executing a task in the first-in, first-out order.

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

What does a serial dispatch queue do?

A

A serial dispatch queue runs tasks one at a time.

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

What does a concurrent dispatch queue do?

A

A concurrent dispatch queue runs as many tasks as it can without waiting for the started tasks to finish.

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

What’s does the main dispatch queue do?

A

A globally available serial queue that executes tasks on the application’s main thread.

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

What are 6 types of pattern matching in Swift?

A
Tuple pattern
Type Casting
Wildcard
Optional 
Enumeration
Expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is tuple pattern matching?

A

used to match values of corresponding tuple types.

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

What is type-casting pattern matching?

A

allow you to cast or match types

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

What is wildcard pattern matching?

A

match and ignore any kind and type of value

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

What is optional pattern matching?

A

used to match optional values

21
Q

What is enumeration pattern matching?

A

match cases of existing enumeration types.

22
Q

What is expression pattern matching?

A

allow you to compare a given value against a given expression.

23
Q

What are 3 benefits of guard statements?

A
  • Safely unwrap optionals
  • Avoid if let pyramids
  • Provides an early exit of the function
24
Q

Name 3 debugging tools in Xcode

A
  • View debugger
  • Thread sanitizer
  • Memory graph debugger
25
Q

What is the difference between a public class and an open class?

A

Open classes can be overidden in a subclass. Public classes allow access but no subclassing or overriding

26
Q

What are the 9 steps in a the view lifecycle order (in order)?

A
  • loadView
  • viewDidLoad
  • viewWillAppear
  • viewWillLayoutSubviews
  • viewDidLayoutSubviews
  • viewDidAppear
  • viewWillDisappear
  • viewDidDisappear
  • viewWillTransition(to:with:)
27
Q

What are the 5 states of an application?

A
  • Non-running
  • Inactive
  • Active
  • Background
  • Suspended
28
Q

Explain the key points to how ARC works

A

ARC is automatic reference counts. It tracks the references to a given object In memory. When an object’s ARC is 0, its removed from memory

29
Q

How are value types managed in memory? Does ARC need to need to be used?

A

Swift automatically handles value types. Value types are not managed by ARC

30
Q

What is a retain cycle?

A

The number of references to an object in ARC does not equal 0 and therefore cannot be removed from memory. If 2 strong objects are referencing each other, they will be never be removed from memory.

31
Q

What is another name for a circular reference?

A

A retain cycle and circular reference are the same thing

32
Q

Will a weak reference increase an ARC count?

33
Q

Will a strong reference increase an ARC count?

34
Q

What type are classes?

A

A reference type

35
Q

What type are structs?

A

A value type

36
Q

What advantage does a class have over a struct?

A

Classes can inherit from other classes and can be used with identity operators

37
Q

What advantages does a struct have over a class?

A

Doesn’t require inheritance and a simple data type

38
Q

How does a value type handle its data?

A

Each copy of a value type is unique and data changes are unique to that instance

39
Q

How does a reference type handle its data?

A

Each copy of the reference shares data. A change made to one is shared to the other references.

40
Q

What type is a closure?

A

Reference type

41
Q

What are the 7 ways to unwrap an optional?

A
  • Forced unwrapping
  • Implicitly unwrapped (don’t specify variable type)
  • Optional binding (if let)
  • Optional chaining (x?.count)
  • Nil coalescing operator (x ?? “”)
  • Guard statement
  • Optional pattern (if case let a? = x)
42
Q

What is a protocol in Swift?

A
  • A style that defines set blueprint of methods, variables, etc. Other classes, structs and enums can then implement them, conforming to the protocol and providing expected consistency
43
Q

What is the difference between a stored property and a computed property?

A
  • Stored: variables or constants that store values to the instance of the object
  • Computed: Does not store values, but used getter and setter to fetching and storing values via computation usually
44
Q

Where can a stored variable be used?

A

Classes and structs

45
Q

Where can a computed value be used?

A

Classes, structs and enums

46
Q

How do you change an internal state of a struct using a function?

A

Mark the function as mutating

47
Q

What does the keyword static mean in a class?

A

It can not be overridden

48
Q

What is the difference between Nil and .none?

A

They are the same. Nil is preferred convention