开发者

Format integer to 2 places

开发者 https://www.devze.com 2023-01-16 21:03 出处:网络
I\'m trying to format integer to 2 characters, i.e. 01, 02, 03 instead of 1, 2, 3, 4. I\'ve done a few google searches but could not find anything. Can @\"%d\" be changed to reflect 2 characters ?

I'm trying to format integer to 2 characters, i.e. 01, 02, 03 instead of 1, 2, 3, 4.

I've done a few google searches but could not find anything. Can @"%d" be changed to reflect 2 characters ?

timeArray = [[NSMutableArray allo开发者_运维技巧c] init];
 for (int i = 0; i < 25; i++){
  NSString *timeValue = [NSString stringWithFormat:@"%d", i];
  [timeArray addObject:timeValue];
  NSLog(@"Time: %@", timeValue);
 }

Regards, Stephen


Got it !!!!

@"%02d"

0

精彩评论

暂无评论...
验证码 换一张
取 消