Re: -hexValue for NSString?
Re: -hexValue for NSString?
- Subject: Re: -hexValue for NSString?
- From: Dave Keck <email@hidden>
- Date: Mon, 23 Mar 2009 15:25:26 -1000
I think this should do the trick:
@implementation NSString (HexIntValue)
- (unsigned int)hexIntValue
{
NSScanner *scanner;
unsigned int result;
scanner = [NSScanner scannerWithString: self];
[scanner scanHexInt: &result];
return result;
}
@end
Note that I would expect -hexValue to be a method of NSNumber, that
would return an NSString of the receiver's hex-value representation. I
titled the method above 'hexValueInt' to more closely match NSString's
-intValue, -floatValue, etc.
David
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden