I want to convert an integer value to a string with leading zeroes (if necessary) such that the string has 3 total characters. For example, 5
would become "005"
, and 10
would become "010"
.
I've tried this code:
NSString* strName = [NSString stringWithFormat:@"img_00%d.jpg", i];
This partially works, but if i
has the value of 10
, for example, the result is img_0010.jpg
, not img_010.jpg
.
Is there a way to do what I want?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…