views:

176

answers:

2
NSString *x = @"12345";
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?

+6  A: 
  NSLog(@"%d", nsint);

%x means hex format. Duh. (See http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265 for all format specifiers.)

KennyTM
Oops, someone had told me %x was integer and %d was double. Thanks.
Rob Lourens
+4  A: 
NSLog(@"%d", nsint);

%x prints hex; %d prints decimal.

WhirlWind