Yot*_*tes 3 iphone nsnumber nsnumberformatter ios
也许这是一个愚蠢的答案,但我对ios很新.我必须在我的应用程序中以特定的方式显示一个数字.目前,我有从NSString中的服务收到的数字.但是,例如,如果我有一个数字:123456789,我需要在标签中显示为123.456.789 ..任何人都知道是否有某种方法可以做到这一点?
编辑:添加ios和iphone标签
用途NSNumberFormatter:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *formattedOutput = [formatter stringFromNumber:[attributesDict objectForKey:NSFileSystemFreeSize]];
NSLog(@"System free space: %@", formattedOutput);
Run Code Online (Sandbox Code Playgroud)
如果您的号码首先以字符串形式出现,您需要首先使用其中NSString的intValue方法创建一个数字:
| 归档时间: |
|
| 查看次数: |
1781 次 |
| 最近记录: |