开发者

NSString integerValue returns a number in hex

开发者 https://www.devze.com 2022-12-25 22:31 出处:网络
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 th
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消