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?

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
Are ranges hashable?
No
26
How do you unwrap an optional?
if let statement
27
What does the import keyword do?
Accesses code that is written in the framework.
28
Bundles of code specialized for a certain purpose that we can use in our projects
Framework
29
What is a Plist?
Property's List is apples own data format that makes it easy to store simple data like numbers, strings, and truth values
30
What is JSON?
Short form "JavaScript Object Notation" uses data to communicate between devices.
31
What is a Key in Plist?
A unique string that identifies a value (unless an array is specified)
32
What is a Type in Plist?
A type of value that exists in a key.
33
What is a value in Plist?
The value that exists in the key.
34
A way for us to covert an object of one type to another type.
Conditional Downcasting
35
Will the conversion of a downcast fail of the literal value in the Plist is not the one you specified?
Yes
36
What does let declaration = Bundle.main.url(forResource: String, withExtension: String)! do?
Starts extraction of the Plist data
37
``` What does let studentsDictionary = NSDictionary(contentsOfURL: studentsPlist) as! [String:Any] do? ```
Convert the Plist dictionary to a swift type dictionary.
38
What does ``` if let shawn = studentsDictionary["Shawn"] as? [String:Any] { // continue extracting values... } ``` do?
Convert each student item into it's own dictionary type.
39
How are JSON arrays specified?
By brackets. []
40
What are JSON objects specified with?
Curly braces {}.
41
What is key: value syntax?
Key-Value pair.
42
What is key: value syntax?
Key-Value pair.