Code Structure
ViewController
:IBOutlet
: control + click on element in storyboard and drop the mouse into viewController file, click connectIBAction
: control + click on the button and drag it to the code -> pops up action editing panel
Storyboard
1 | class ViewController: UIViewController { |
- String
1 | var s = "some example string with \(variable)" |
- Range operator
1 | let randomNumber = Int.random(in: 1 ... 3) // closed range [1, 3] |
- Switch
1 | switch score { |
- Dictionary
1 | var dict : [String: Int] = ["Key": value] |
- Optionals
1 | var hardness: String? = nil |
- Timer
1 | var timer = Timer() |
- Float
1 | let a = 5 |
- Struct
Struct name starts with a capital letter
1 | struct Town { |