Click to rate this post!
[Total: 1 Average: 5]
Last Updated on March 13, 2022 by Deya Eldeen
Swift is strongly typed, data should either be explicitly assigned or inferred, the main basic data types that come with swift are
|Character||a 16-bit Unicode character like “a” or “/”|
|String||represents textual data like “Hello”|
|Float||represents 32-bit floating-point number|
|Double||represents 64-bit floating-point number|
|Bool||logical value: true or false|
|Tuples||groups multiple values in single value|
|Int||integer, a whole number|
|UInt||unsigned integer, a whole number|
|Int8||1 byte integer|
|Int32||4 bytes integer|
|Int64||8 bytes integer|
|UInt8||1 byte unsigned integer|
|UInt32||4 bytes unsigned integer|
|UInt64||8 bytes unsigned integer|
On a 32-bit device, Int has the size of Int32, on 64-bit devices, Int has the size of Int64, same goes for UInt.
Swift has a feature where it can infer the type of the data directly, for example the variable level here is infered to be an Int
var level = 12
you can explicitly determine the type directly
var level: Int = 17 Extra Tip: A CGFloat holds either 32-bits of data or 64-bits of data depending on the CPU Architecture.