Sorry Graham - I should have mentioned that the color is rgba within
the uint32.
Thanks everyone - Robs solution worked great, though I'll have to
strip off the # first and then shift to the left a further 8 bits.
Never used NSScanner before but its a good solution.
On 27/08/2009, at 9:50
Here's what we use to convert from an ARGB hex value to an NSColor -
you could perhaps use a similar method and just shift the bytes and or
them together as required for your unsigned int.
+ (NSColor *)colorWithHexARGB:(NSString*)hexString {
unsigned int redByte, greenByte, blueByte,
Peter,
I use NSScanner to parse the string to get individual values.
NSRange range = NSMakeRange(1, 2);
NSUInteger value = 0;
[[NSScanner scannerWithString:[string substringWithRange:range]]
scanHexInt:&value]
// WARNING: code typed in email
--Waqar
On Aug 26, 2009, at 4:50 PM, Peter Zege
On 27/08/2009, at 9:50 AM, Peter Zegelin wrote:
I have some xml where an rgb color value is specified via a
"#XXYYZZ" type string. The xml is being read in via NSXMLParser. I
can't seem to find an easy Cocoa way to convert this value to an
unsigned int. I need an unsigned int rather than a
On 27/08/2009, at 9:50 AM, Peter Zegelin wrote:
Hi,
I have some xml where an rgb color value is specified via a
"#XXYYZZ" type string. The xml is being read in via NSXMLParser. I
can't seem to find an easy Cocoa way to convert this value to an
unsigned int. I need an unsigned int rather
Hi,
I have some xml where an rgb color value is specified via a "#XXYYZZ"
type string. The xml is being read in via NSXMLParser. I can't seem to
find an easy Cocoa way to convert this value to an unsigned int. I
need an unsigned int rather than an NSColor as the value is used in C+
+ code.