iOS Apprentice Flashcards

1
Q

What happens when you press Run?

A

The compiler is the part of Xcode that converts your Swift source code into executable binary code

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

The complete set of frameworks for iOS is known collectively as?

A

Cocoa Touch

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

With what UIKit works to represente size on screen

A

Points

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

Three possible scope levels in Swift

A

Global scope: These objects exist for the duration of the app and are accessible from anywhere.

Instance scope: This is for variables such as currentValue. These objects are alive for as long as the object that owns them stays alive.”

“Local scope: Objects with a local scope, such as the slider parameter of sliderMoved(), only exist for the duration of that method. As soon as the execution of the program leaves this method, the local objects are no longer accessible.”

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

What is info.plist?

A

Info.plist is a configuration file inside the application bundle that tells iOS how the app will behave. It also describes certain characteristics of the app, such as the version number, that don’t really fit anywhere else.

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

What happens if you don’t add any constraints to your views?

A

In that case, Xcode will automatically add constraints when it builds the app.”

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

In order to allow Xcode to put an app on your iPhone?

A

the app must be digitally signed with your Development Certificate. A certificate is an electronic document that identifies you as an iOS application developer and is valid only for a specific amount of time.

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

Apps that you want to submit to the App Store must

A

be signed with the Distribution Certificate.

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

Xcode uses this to sign the app for use on your particular device (or devices)

A

Provisioning Profile

you need a provisioning profile or the app won’t go on your device.

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

What the difference is between the terms property and instance variable?

A

In Swift terminology, a property is a variable or constant that is used in the context of an object. That’s exactly what an instance variable is.
(In Objective-C, properties and instance variables are closely related but not quite the same thing. In Swift they are the same.)”

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

Cleaning code flow

A

When write code until it becomes messy and then you clean it up. After a little while it becomes a big mess again and you clean it up again.

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

NSRange vs. Range

A

NSRange is an Objective-C structure whereas Range is its Swift equivalent - they are similar, but not exactly the same. So, while an NSRange parameter is used by the UITextField (which internally, and historically, is Objective-C based) in its delegate method, in our Swift code, if we wanted to do any String operations, such as replacingCharacters, then we need a Range value instead. Swift methods generally use Range values and do not understand NSRange values, which is why we converted the NSRange value to a Swift-understandable Range value.

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

Segue flow in steps

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

Equal vs identical

A

If you use ==, you’re checking whether two variables have the same value.”
“With === you’re checking whether two variables refer to the exact same object.

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

UInt vs Int

A

The U stands for unsigned, meaning the data type can hold positive values only. It’s called unsigned because it cannot have a negative sign (-) in front of the number.

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

CGFloat vs Float

A

CGFloat. This isn’t really a Swift type but a type defined by the iOS SDK. It’s a decimal point number like Float and Double. For historical reasons, this is used throughout UIKit for floating-point values. (The “CG” prefix stands for the Core Graphics framework.)

17
Q

%f vs %.8f

A

The .8 means that there should always be 8 digits behind the decimal point.

18
Q

UI objects hierarchy from NSObject

A
19
Q

assert() in code

A

An assertion is a special debugging tool that is used to check that your code always does something valid. If not, the app will crash with a helpful error message.

Assertions are usually enabled only while you’re developing and testing your app and disabled when you upload the final build of your app to the App Store

20
Q

Unwind segue

A

Unwind segue closes the active scree

21
Q

Mutating keyword

A

When a method changes the value of a struct, it must be marked as mutating. Recall that String is a struct, which is a value type, and therefore cannot be modified when declared with let.

You don’t need to use the mutating keyword on methods inside a class because classes are reference types and can always be mutated, even if they are declared with let

22
Q

“appearance proxy”

A

to change the look of all of the controls of a particular type at once.”

23
Q

common technique for building complex layouts

A

Grouping views in a container view

24
Q

Associated values in enums

A

They let you associate a custom value (or values) with each enumeration case.

  1. Each enumeration case has zero or more associated values.
  2. The associated values for each enumeration case have their own data type.
  3. You can define associated values with label names like you would for named function parameters.
25
Q

An enumeration can have raw values and associated values?

A

An enumeration can have raw values OR associated values, but not both.

26
Q

associated value in enum with guard

A
27
Q

Enumerations without any cases

A

*Uninhabited enumerations*can be used as namespaces and prevent the creation of instances.

28
Q

Required init - when?

A

If you conform to a protocol with required initializers using a class type, those initializers must use the required keyword:

29
Q

Your choices for implementing a get requirement in protocol are

A

* A constant stored property.
* A variable stored property.
* A read-only computed property.
* A read-write computed property.

30
Q

Associated types in protocols

A

using associatedtype in a protocol, you’re simply stating there isa type used in this protocol, without specifying what type this should be. *It’s up to the protocol adopter to decide what the exact type should be.*

31
Q

Protocol composition

A

Imagine you need a function that needs access to the Vehicle protocol’s stop() function and the Wheeled protocol’s numberOfWheels property. You can do this using the & composition operator.

32
Q

If you’re designing a protocol to be adopted exclusively by classes, it’s best to

A

to request that Swift uses reference semantics when using this protocol as a type.

: class

33
Q

is a requirement for any type you want to use as a key to a Dictionary.

A

The Hashable protocol, a subprotocol of Equatable

34
Q

Type constraints

A

Pet requires that the type assigned to Animal must be a subclass of Pet, if Pet is a class, or must implement the Pet protocol, if Pet is a protocol.

class Keeper <t: animal></t:>

35
Q

Generic parameter in func

A

Generics are like functions for the compiler. They are evaluated at compile time and result in new types which are specializations of the generic type.

Think of the type parameters as arguments for the compiler, which it uses to define one possible function.

36
Q

When the collection view needs some layout information, it asks

A

your layout object to provide it by calling certain methods in a specific order: