SWIFT Basic Syntax – Data Type

Common Swift data types

value type enum Optional
structure (Struct) Bool, Int, Float, Double, Character
String, Array, Dictionary, Set
reference type class class

Share a picture

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

Share a picture

while

Share a picture

for

Sw The use of ift’s for loop is combined with the interval type. Interval type in Swift

share picture

< p>for loop use

share picture

If the variable i is not used in the for loop body, you can use _omit

share picture

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" >

Leave a Comment

Your email address will not be published.