NSString integerValue returns a number in hex
NSString *x = @"12345";开发者_Go百科
NSInteger nsint = [x integerValue];
NSLog(@"%x", nsint);
Prints 3039. intValue has the same result. Any idea how I can get the actual decimal value out of that?
NSLog(@"%d", nsint);
%x
means hex format. (See http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265 for all format specifiers.)
NSLog(@"%d", nsint);
%x prints hex; %d prints decimal.
精彩评论