Swift Flashcards

1
Q

What is a nil value?

A

Nothing

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

What is the purpose of nil?

A

Used to represent the absence of a value.

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

Can ints be assigned to nil?

A

False

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

Can ints be assigned to objects?

A

False

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

What is a function?

A

Self contained chucks of code that performs a specific task.

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

Do you give a name to a function to be called upon?

A

Yes

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

What is a method?

A

Functions that are associated with a particular type.

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

What are some instance methods in swift?

A

Classes, structures, and enumerations because they all encapsulate a specific task.

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

What is a syntax?

A

Specific rules and symbols that are considered correctly structured in code.

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

Does every function in swift have a type?

A

True

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

What is a return statement?

A

Tells the program to return to the original address.

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

What is () called?

A

Placeholder

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

What does a if/else statement do?

A

If a condition is met execute the code else execute the second line of code.

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

> , =, <=

These are examples of what kind of operators?

A

Comparison Operators

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

What is an instance?

A

A var defined in a class.

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

What is nesting?

A

Loops that contain other loops.

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

What does % 2 == 0 do?

A

Tests evenness.

18
Q

What does % 2 == 1 do?

A

Tests oddness.

19
Q

What does sum do?

A

Causes the playground to print a total sum.

20
Q

Are dictionaries ordered or unordered?

A

Unordered

21
Q

What are dictionaries?

A

You type in a key (keyword) and the program returns a value.

22
Q

What is initialization?

A

The process of preparing an instance, class, structure, enumeration for use.

23
Q

What is … ?

A

A closed range operator.

24
Q

What is hashable?

A

A special function that can change each key into a integer.

25
Q

Are ranges hashable?

A

No

26
Q

How do you unwrap an optional?

A

if let statement

27
Q

What does the import keyword do?

A

Accesses code that is written in the framework.

28
Q

Bundles of code specialized for a certain purpose that we can use in our projects

A

Framework

29
Q

What is a Plist?

A

Property’s List is apples own data format that makes it easy to store simple data like numbers, strings, and truth values

30
Q

What is JSON?

A

Short form “JavaScript Object Notation” uses data to communicate between devices.

31
Q

What is a Key in Plist?

A

A unique string that identifies a value (unless an array is specified)

32
Q

What is a Type in Plist?

A

A type of value that exists in a key.

33
Q

What is a value in Plist?

A

The value that exists in the key.

34
Q

A way for us to covert an object of one type to another type.

A

Conditional Downcasting

35
Q

Will the conversion of a downcast fail of the literal value in the Plist is not the one you specified?

A

Yes

36
Q

What does

let declaration = Bundle.main.url(forResource: String, withExtension: String)!

do?

A

Starts extraction of the Plist data

37
Q
What does 
let studentsDictionary = NSDictionary(contentsOfURL: studentsPlist) as! [String:Any] 
do?
A

Convert the Plist dictionary to a swift type dictionary.

38
Q

What does

if let shawn = studentsDictionary["Shawn"] as? [String:Any] {
    // continue extracting values...
}

do?

A

Convert each student item into it’s own dictionary type.

39
Q

How are JSON arrays specified?

A

By brackets. []

40
Q

What are JSON objects specified with?

A

Curly braces {}.

41
Q

What is key: value syntax?

A

Key-Value pair.

42
Q

What is key: value syntax?

A

Key-Value pair.