Re: NSString's intValue method
Re: NSString's intValue method
- Subject: Re: NSString's intValue method
- From: Ondra Cada <email@hidden>
- Date: Mon, 19 Apr 2004 12:52:48 +0200
On 19.4.2004, at 12:41, p3consulting wrote:
>
- (unsigned int)uintValue
>
{
>
return strtoul([self cString], NULL, 10);
>
}
[self UTF88String] may be somewhat better in the long prospect perhaps:
cString has been marked as deprecated, so it may disappear sooner or
later.
Besides, there's another issue with cString: may raise a
NSCharacterConversionException, even in a completely valid (from the
uintValue point of view) situations. Also it is arguable whether the
possible inefficiency of using an NSScanner would not be more
acceptable than the possible inefficiency of translating a whole,
possibly pretty long string: it depends on your programming habits, I
guess ;)
Finally, much better name for the method might be unsignedIntValue, to
keep consistency and polymorphism:
unsigned u=[o unsignedIntValue]; // would work all right regardless o
is NSNumber or NSString
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.