iphone - 将整数格式化为 2 位

标签 iphone integer

我正在尝试将整数格式化为 2 个字符,即 01、02、03,而不是 1、2、3、4。

我已经进行了一些谷歌搜索,但找不到任何东西。 @"%d"可以更改为反射(reflect) 2 个字符吗?

timeArray = [[NSMutableArray alloc] init];
 for (int i = 0; i < 25; i++){
  NSString *timeValue = [NSString stringWithFormat:@"%d", i];
  [timeArray addObject:timeValue];
  NSLog(@"Time: %@", timeValue);
 }

问候, 斯蒂芬

最佳答案

明白了!!!

@“%02d”

关于iphone - 将整数格式化为 2 位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3762119/

相关文章:

ios - 将付费应用升级为免费应用

Python 列表类型

Haskell Int -> Word64 转换

python - Python3中的整数溢出

java - 为什么相等运算符适用于整数值直到 128 数字?

iPhone 应用架构

ios - iOS 和 AirPlay 上的 Widevine 视频流

ios - 自动布局约束在动画后不起作用

iphone - UITableViewCell 文本标签偏移量

java - 如何显示 - ArrayList<Integer[]> lista = new ArrayList<>()