In this tutorial, we are going to learn about how to convert a int(Integer) to string with leading zeros in Swift.
To convert int to a string by adding leading zeros, we can use the Strings
Here is an example, that adds leading 0 to the
import Foundation let str1 = String(format: "%02d", 1); print(str1);
If you want to add two leading zeros, you can do it like this.
import Foundation let string0 = String(format: "%03d", 1); print(string0); // 001