Re: A Question on estimating +arrayWithCapacity
Re: A Question on estimating +arrayWithCapacity
- Subject: Re: A Question on estimating +arrayWithCapacity
- From: Ashley Clark <email@hidden>
- Date: Sat, 10 Jan 2009 11:29:27 -0600
On Jan 10, 2009, at 2:10 AM, Bill Bumgarner wrote:
On Jan 9, 2009, at 7:11 PM, Ashley Clark wrote:
This should apply to NSNumber and NSDecimalNumber too right? Yet
the NSNumber +numberWith... methods are declared to return
(NSNumber *) and when called on NSDecimalNumber they return
NSDecimalNumber objects which then have to be typecast.
The "need" for a typecast indicates that you are using the API
incorrectly. That the +numberWith...: variants are declared as
returning (NSNumber *) is very likely an explicit indication as to
their purpose and limitations.
That it seemingly works by the use of typecasting is a coincidence
of implementation.
Instead, you should use one of the following methods to create
NSDecimalNumbers:
Ok, that's what I thought originally but I had seen somewhere (on this
list maybe?) people advocate the use of the numberWith... superclass
methods to create NSDecimalNumbers from float and integer constants.
If you don't like the declared behavior of the classes, file a bug
-- http://bugreporter.apple.com/ -- with a description of the change
desired (and an example, if possible).
Filed. At least in the case of float, double, short, int, long and
long long it would be nice to be able to use the superclass' methods
instead of this:
NSDecimalNumber *five = [NSDecimalNumber decimalNumberWithDecimal:
[[NSNumber numberWithInt:5] decimalValue];
or
NSDecimalNumber *five = [NSDecimalNumber decimalNumberWithString:@"5"];
Ashley
_______________________________________________
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