Le 7 oct. 08 à 07:08, Cyrus Najmabadi a écrit :
I've been unsuccessful finding the right class in cocoa to help me
parse
integers inside NSStrings.
I'm looking for something similar to java's Long.parseInt(string,
radix).
i.e. something that can understand a stream of numbers along with a
specified radix (which may be 8, 10 or 16 in my use cases).
What is available to help out here?
Thanks!
-- Cyrus
For base 10, -[NSString integerValue] will do the trick, for other
bases, you can either use NSScanner, or just fall back to libc function:
strtol([myString UTF8String], NULL, 16);
I don't remember if -UTF8String may returns NULL. If this is the case,
you should test the value before passing it to strtol.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]