March 2017
Intermediate to advanced
226 pages
5h 13m
English
Here are a few quick rules that apply to declaring constants and variables of number types:
Prefer Int to more specialized variants unless you need to work with a specific size of integer. Int supports code consistency and interoperability and is fully supported on 32-bit as well as 64-bit platforms.
Reserve UInt use for when you specifically need an unsigned integer using the platform’s native word size. In all other cases, Apple recommends you prefer Int, even when values are known to be non-negative. Apple writes, “A consistent use of Int for integer values aids code interoperability, avoids the need to convert between different number types, and matches integer type inference.”
Prefer Double to
Read now
Unlock full access