Common Swift data types
value type | enum | Optional |
structure (Struct) | Bool, Int, Float, Double, Character | |
String, Array, Dictionary, Set | ||
reference type | class | class |
Swift flow control
- The () after the flow control if, while, for in Swift can be omitted, and the brace after the condition cannot be omitted
- Starting from Swift3, the increment and decrement operators are removed
- repeat-while is equivalent to do-while in C language
if-else
while
for
Sw The use of ift’s for loop is combined with the interval type. Interval type in Swift
< p>for loop use
If the variable i is not used in the for loop body, you can use _omit
The interval operator is used on the array for loop traversal
< img alt="share picture" src="/wp-content/uploads/images/mobile/swift/1626792707727.png" width="700" >