Skip to main content
3 of 10
deleted 258 characters in body
vacawama
  • 155.1k
  • 32
  • 283
  • 315

Assuming you want a field length of 2 with leading zeros you'd do this:

for myInt in 1...3 { println(String(format: "%02d", myInt)) } 

This requires import Foundation so technically it is not a part of the Swift language but a capability provided by the Foundation framework.

vacawama
  • 155.1k
  • 32
  • 283
  • 315