Chr*_*ris 2 iphone formatting numbers objective-c nsstring
快速问题:我试图用NSString stringWithFormat格式化字符串填充具有特定数量的零的空格.
例如,我想:
@"The number is %d", 5 // I want this to output 'the number is 05'
@"the number is %d", 10 // I want this to output 'the number is 10'
Run Code Online (Sandbox Code Playgroud)
我知道如何用Java做到这一点,但我似乎无法在objective-c中找到相同的功能.
任何帮助都会很棒.
Bol*_*ock 15
如果在Java中使用System.out.printf(),则它与Objective-C(和C)中的格式语法相同:
NSLog(@"The number is %02d", 5);
NSLog(@"The number is %02d", 10);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1344 次 |
| 最近记录: |