Cha*_*har 3 iphone nsstring unsigned-integer
我有一个未定义的int值为-10,现在我想将其转换为NSString.
简单地说,我们在objective-c中进行iphone编程
int x = 10;
NSString *str = [NSString stringWithFormat:@"%d",x];
NSLog(@"My String is %@",str);
Run Code Online (Sandbox Code Playgroud)
我将控制台输出显示为10
但如果是这样的话
unsigned int x = -10;
NSString *str = [NSString stringWithFormat:@"%d",x];
NSLog(@"My String is %@",str);
Run Code Online (Sandbox Code Playgroud)
然后输出将是相同的,而不是-10,
我怎样才能进行适当的转换?
| 归档时间: |
|
| 查看次数: |
7535 次 |
| 最近记录: |