I have an unsinged int having value of -10,
now I want to convert it into NSString
.
In simply we do as, in objective-c, iphone programming
int x = 10;
NSString *str = [NSString stringWithFormat:@"%d",x];
NSLog(@"My String is %@",str);
I will show console output as 10
but if it is something like
unsigned int x = -10;
NSString *str = [NSString stringWithFormat:@"%d",x];
NSLog(@"My String is %@",str);
Then the output will be same, not the -10,
how can I do proper conversion ?
Use %u
instead of %d
. It is similar to C : Convert signed to unsigned.