• 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: A Question on estimating +arrayWithCapacity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >A Question on estimating +arrayWithCapacity (From: Steve Cronin <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Graham Cox <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Ken Thomases <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: "Kyle Sluder" <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Graham Cox <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: mmalc Crawford <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Ashley Clark <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: A Data Object in Cocoa
  • Next by Date: Re: A Data Object in Cocoa
  • Previous by thread: Re: A Question on estimating +arrayWithCapacity
  • Next by thread: A Data Object in Cocoa
  • Index(es):
    • Date
    • Thread