Swift Flashcards

1
Q

In swift:

Function to retrieve a count of the characters of a string

A

countElements ()

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

In swift:

How can load xib file

A

NSBundle.mainBundle().loadNibNamed: owner: options:

Other way:
UINib(nibName: bundle:)
nib.instantiateWithOwner: options:

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

In swift:

How can compare two strings?

A

Using operator == and !=

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

In swift:

String method to check prefix and suffix.

A

hasPrefix (“”)

hasSuffix (“”)

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

In swift:

How can be converted an int to String?

A

Using casting:

String(intValue)

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

In swift:

How to convert a string to integer?

A

stringVar.toInt()

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

In swift:

How to iterate an array and know the index and value?

A

Using enumerate function:

for (index, value) in enumerate(shoppingList) {
println(“Item (index + 1): (value)”)
}

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

In swift:

Method to remove an element of an array?

A

removeAtIndex()

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

In swift:

Function to know if an array contains an element?

A

contains( , value)

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

In swift:
A shorthand for code:
a != nil ? a! : b

A

(a ?? b)

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

In swift:

How to load a ViewController from Storyboard?

A

UIStoryboard(name: “Main”, bundle: nil).instantiateViewControllerWithIdentifier(“AnID”) as MyViewController

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