Professional Documents
Culture Documents
Cheat Sheet Swift Assist Software Romania 0
Cheat Sheet Swift Assist Software Romania 0
No
Yes viewWillAppear
viewExist? viewDidAppear
Appearing
Use reduce to combine all items in a collection to create a printSomeString() //-> Hello start function!
single new value. Hello end function!
Hello inside the defer!
Example:
Switch Example:
You can apply a switch to multiple data types: String, Enum, protocol CarProtocol {
Int, Float, and other types.
var model: String { get }
var HP: Int { get }
Example:
var type: String { get }
let someString: String = "first" func description() -> String
switch <value> { }
case <pattern>:
<code> class Car: CarProtocol {
default: var color: String
<code> let model: String
} let HP: Int
var type: String
init(model: String, HP: Int, type: String) {
self.model = model
Default parameter function self.HP = HP
self.type = type
If you omit the second argument when calling this self.color = "Red"
function, then the value of parameterWithDefault is 12 inside }
the function body.
func description() -> String {
Example: return " Model: \(model) \n Color: \(color) \n Type: \(type )
\n Power: \(HP) HP \n"
func someFunction( parameterWithoutDefault: Int, }
parameterWithDefault: Int = 12) { } }
Example:
assist-software.net