Are there any Cocoa classes that will help me convert a hex value in a NSString like 0x12FA to a long or NSNumber? It doesn't look like any of the classes like NSNumberFormatter support hex numbers.
0x12FA
long
NSNumber
NSNumberFormatter
Thanks, Hua-Ying
Here's a short example of how you would do it using NSScanner:
NSString* pString = @"0xDEADBABE"; NSScanner* pScanner = [NSScanner scannerWithString: pString]; unsigned int iValue; [pScanner scanHexInt: &iValue];
2.1m questions
2.1m answers
60 comments
57.0k users