• 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: Convert hexadecimal NSString (0xff00) to decimal integer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert hexadecimal NSString (0xff00) to decimal integer?


  • Subject: Re: Convert hexadecimal NSString (0xff00) to decimal integer?
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Tue, 7 Jan 2003 11:38:58 -0500

On Tuesday, Jan 7, 2003, at 11:20 US/Eastern, Daniel Ericsson wrote:

On tisdag, jan 7, 2003, at 14:54 Europe/Stockholm, Greg Hurrell wrote:

Perhaps it's bleedingly obvious and staring me in the face, but I couldn't find any shortcuts in NSString or NSNumber that might do this conversion in one hit... and I find that odd because Apple obviously has code which does this (if you look at the way their code can parse plists it's evident they have plenty of tricks for converting between various types of strings and numbers etc).

I agree, for completeness sake, there should be a way to get an integer from a hexadecimal NSString using the Cocoa frameworks (if it's there I can't see it either).

You could use NSScanner:

{
unsigned result;
if([[NSScanner scannerWithString: aString] scanHexInt: &result])
NSLog(@"Conversion succeeded: %u", result);
else
NSLog(@"Conversion failed");
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Convert hexadecimal NSString (0xff00) to decimal integer? (From: Daniel Ericsson <email@hidden>)

  • Prev by Date: Re: Converting OSX Path to a OS9 Path
  • Next by Date: Re: porting apps from NextStep to Cocoa
  • Previous by thread: Re: Convert hexadecimal NSString (0xff00) to decimal integer?
  • Next by thread: Re: creating an NSImage from an NSView
  • Index(es):
    • Date
    • Thread