Swift Flashcards
In swift:
Function to retrieve a count of the characters of a string
countElements ()
In swift:
How can load xib file
NSBundle.mainBundle().loadNibNamed: owner: options:
Other way:
UINib(nibName: bundle:)
nib.instantiateWithOwner: options:
In swift:
How can compare two strings?
Using operator == and !=
In swift:
String method to check prefix and suffix.
hasPrefix (“”)
hasSuffix (“”)
In swift:
How can be converted an int to String?
Using casting:
String(intValue)
In swift:
How to convert a string to integer?
stringVar.toInt()
In swift:
How to iterate an array and know the index and value?
Using enumerate function:
for (index, value) in enumerate(shoppingList) {
println(“Item (index + 1): (value)”)
}
In swift:
Method to remove an element of an array?
removeAtIndex()
In swift:
Function to know if an array contains an element?
contains( , value)
In swift:
A shorthand for code:
a != nil ? a! : b
(a ?? b)
In swift:
How to load a ViewController from Storyboard?
UIStoryboard(name: “Main”, bundle: nil).instantiateViewControllerWithIdentifier(“AnID”) as MyViewController