I want to convert a two hexadecimal number to an integer but I'm having some difficulty. The format is "#FF" and I want to convert it to 255 or "#00" and convert to 0. However when I try the following:
unsigned alphaColor = 0;
[[NSScanner scannerWithString:alphaString] scanHexInt:&alphaColor];
alphaVal = alphaColor / 255.0;
It seems to not work as alphaColor is nil. Any ideas how I can convert a two digit hexadecimal?
scanHexIntdoes not accept the#. It optionally allows for a leading0xor0xbut not#. You need to read the#first.