Creates a new integer value from the given string and radix.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
Parameters
text
The ASCII representation of a number in the radix passed as
radix
.radix
The radix, or base, to use for converting
text
to an integer value.radix
must be in the range2...36
. The default is 10.
Discussion
The string passed as text
may begin with a plus or minus sign character (+
or -
), followed by one or more numeric digits (0-9
) or letters (a-z
or A-Z
). Parsing of the string is case insensitive.
If text
is in an invalid format or contains characters that are out of bounds for the given radix
, or if the value it denotes in the given radix
is not representable, the result is nil
. For example, the following conversions result in nil
: