• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: -hexValue for NSString?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -hexValue for NSString?


  • Subject: Re: -hexValue for NSString?
  • From: Ali Ozer <email@hidden>
  • Date: Mon, 23 Mar 2009 18:16:28 -0700

NSScanner has

- (BOOL)scanHexInt:(unsigned *)value; // Optionally prefixed with "0x" or "0X"
- (BOOL)scanHexLongLong:(unsigned long long *)result;


so you can

unsigned yourValueHere;
BOOL success = [[NSScanner scannerWithString:string] scanHexInt:&yourValueHere];


Ali

On Mar 23, 2009, at 6:00 PM, Jonathon Kuo wrote:

In NSString theres -intValue, -floatValue, -doubleValue, but no - hexValue (that I can find). I'd like to convert ascii hex NSStrings (@"001A4CD3" etc) into integer values. Having a -hexValue method would make that a snap. If theres no Cocoa way, I guess I could try my hand at writing a category(?) method on NSString using sscanf with %x.


_______________________________________________

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


  • Follow-Ups:
    • Re: -hexValue for NSString?
      • From: Jonathon Kuo <email@hidden>
References: 
 >-hexValue for NSString? (From: Jonathon Kuo <email@hidden>)

  • Prev by Date: Re: IB instantiating objects
  • Next by Date: Simulating (or obtaining) menubar effect in a Cell
  • Previous by thread: -hexValue for NSString?
  • Next by thread: Re: -hexValue for NSString?
  • Index(es):
    • Date
    • Thread