I want to ask very simple thing about conversion between type.
int theinteger = 75;
NSLog(@"Before theinteger is: %@", theinteger);
NSString *string = [NSString stringWithFormat:@"%d", theinteger];
NSLog(@"After theinteger is: %@", string);
Output is like
Before theinteger: 75
After theinteger: 114503696
What does this mean? Why after conversion my data is changed to 114503696?
When I tried
int theinteger = -1;
It’s OK
Before theinteger: -1
After theinteger: -1
Am I missing something?
Without seeing any evidence of it, I assume
theintegeris, in fact, of typeNSIntegerorint.When using a specifier, try using %i:
Output
Here’s a list of specifiers.