• 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: Bill Bumgarner <email@hidden>
  • Date: Sat, 10 Jan 2009 00:10:16 -0800

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:

+ (NSDecimalNumber *)decimalNumberWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)flag;
+ (NSDecimalNumber *)decimalNumberWithDecimal:(NSDecimal)dcm;
+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)numberValue;
+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)numberValue locale:(id)locale;


+ (NSDecimalNumber *)zero;
+ (NSDecimalNumber *)one;
+ (NSDecimalNumber *)minimumDecimalNumber;
+ (NSDecimalNumber *)maximumDecimalNumber;
+ (NSDecimalNumber *)notANumber;

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).

b.bum
_______________________________________________

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


  • Follow-Ups:
    • Re: A Question on estimating +arrayWithCapacity
      • From: Ashley Clark <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>)

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