Swift – String to Integer

In this tutorial, we will learn how to convert a String to Integer in Swift programming.

To convert a String to Integer, use Int(string_value).

Example 1 – Convert String to Integer

In this example, we take a string variable and convert this to Integer.

main.swift

var str = "256"

var a:Int! = Int(str)

print(a)
print(a+25)

Output

256
281

Conclusion

In this Swift Tutorial, we have learned how to convert a String to Integer in Swift programming.