Swift – Convert Int to String
To convert an Int value to a String value in Swift, use String(). String() accepts integer as argument and returns a String value created using the given integer value.
The syntax to convert an integer x
to String is
</>
Copy
String(x)
Example
In this example, we take an Int value in x
and convert this value to a String value using String() and store it in str
variable..
main.swift
</>
Copy
var x = 256
var str = String(x)
print(str)
Output
Conclusion
In this Swift Tutorial, we have learned how to convert a String to Integer in Swift programming.