Swift Cheat Sheet
Variables/Constants Functions Data Types
var myVariable = 42 func aFunction(input: Type) ->Type { Int 23
let myConstant = 12 //Do Something Float 2.3
var typedVariable: Type return theOutput Double 3.1415926
let typedConstant: Type } Bool true/false
String "abc"
Structures Classes Array [1,2,3]
struct MyStruct { class myClass: SuperClass { Dictionary
} } [key: value]
IF Statement Switch Statement Loops
if condition { switch someVariable { for variable in low...high {
//do X case 1: }
for fruit in fruitBasket { //do something
} elseif otherCondition { //do X
for i in 0...4 { //do something else }
for item in array {
//do Y case 2: } for i in 0..<4 {//do another thing }
} else { //do X
//do Z default: while condition {
} //do X }
}
www.appbrewery.co