Skip to main content
1 of 21
Imanou Petit
  • 93k
  • 31
  • 268
  • 223

When you want to get a String from an Int and format this String, you need to use NSNumberFormatter.

The following code creates a NSNumberFormatter that has at least two integer digits:

let formatter = NSNumberFormatter() formatter.minimumIntegerDigits = 2 for myInt in 1...3 { let str = formatter.stringFromNumber(myInt) println(str) } 
Imanou Petit
  • 93k
  • 31
  • 268
  • 223