• 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
NSDecimalNumber seen as NSCFNumber; a bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDecimalNumber seen as NSCFNumber; a bug?


  • Subject: NSDecimalNumber seen as NSCFNumber; a bug?
  • From: Davide Benini <email@hidden>
  • Date: Thu, 8 Jan 2009 17:49:46 +0100

Hello folks,
I have run into a strange issue.
I have a LineItem class featuring a NSDecimalNumber *unitaryPrice property.
The property works allright all across my app, except in a single view controller.


I have this LineItemDataPickerViewController (UIViewController subclass) with

@property (nonatomic, retain) LineItem *lineItem;

Before displaying it, I set

controller.lineItem = aLineItem;

When the controller is displayed, in the viewWillDisplay:animated: method, I need to set the unitaryPrice value in the appropriate field, but before I perform some rounding.

NSDecimalNumberHandler *roundingBehavior = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundBankers scale:2 raiseOnExactness:FALSE raiseOnOverflow:TRUE raiseOnUnderflow:TRUE raiseOnDivideByZero:TRUE];
NSDecimalNumber *roundedAmount = [lineItem.unitaryPrice decimalNumberByRoundingAccordingToBehavior:roundingBehavior];


And here the application terminates and I get this error message

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFNumber decimalNumberByRoundingAccordingToBehavior:]: unrecognized selector sent to instance 0x10755e0'

for what it'w worthm, I tried also the following change, which was useless.
NSDecimalNumber *roundedAmount = (NSDecimalNumber *) [lineItem.unitaryPrice decimalNumberByRoundingAccordingToBehavior:roundingBehavior];


I spent a couple of hours analysing the flow with the debugger. The controller.lineItem property is correctly set, and the lineItem.unitaryPrice object is seen as a NSDecimalNumber until BEFORE the LineItemDataPickerViewController is loaded and viewWillAppear:animated is called. Then, inside this method, lineItem.unitaryPrice is seen as an "out of scope" NSCFNumber.

I've been googling, and this discussion here is the closest thing I found to my issue:

http://www.cocoadev.com/index.pl?NSDecimalNumbersSeenAsNSNumbers

Any suggestion? Could this be a bug?

Davide

_______________________________________________

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: NSDecimalNumber seen as NSCFNumber; a bug?
      • From: Quincey Morris <email@hidden>
    • Re: NSDecimalNumber seen as NSCFNumber; a bug?
      • From: Ashley Clark <email@hidden>
  • Prev by Date: PDF Problem
  • Next by Date: Re: Encryption and Security
  • Previous by thread: Re: PDF Problem
  • Next by thread: Re: NSDecimalNumber seen as NSCFNumber; a bug?
  • Index(es):
    • Date
    • Thread