Convert Hex Value Stored As NSString To Integer

If you have a hex value that is stored in an NSString object and need to convert the value into an integer, the NSScanner object can be of great help.

Let’s say for example that you need convert the string “0xABCD” to its integer equivalent. Or maybe you are working with values that are related to a color selection, then you may have a value in hex that looks like this “#12BC99.” In either case, the method below will convert the NSString using NSScanner and return an integer.
Continue reading