My online tech scrapbook where I keep my notes in case I need to look them up later
Tuesday, November 6, 2012
iOS: String Format for Numbers With Leading Zeros
To obtain a formatted String with a fixed number or digits, and any shortfall padding by leading zeroes, use the following function call
[NSString stringWithFormat:@"%04d", i];
This will return a String containing the integer "i" and will always be 4 digit long. If i is 1, then the String will be "0001". If it is 12, then the String will be "0012".
No comments:
Post a Comment