objective c - Trouble with NSDecimalNumber's decimalNumberByDividingBy:withBehavior: -
I always run into trouble with NSDecimalNumber! Today, I get this error:
"Expected Exception 'NSInvalidArgumentException', App ended due to reason: '*** - [NSCFNumber decimalNumberByDividingBy: withBehavior:]: Example: 0xd1fb10 '"
- (zero) setUpInstance {Fixed NSDecimalNumberHandler sent for non-recognized selector * RoundingBehavior = nil; If (roundingBehavior == zero) {roundingBehavior = [[NSDecimalNumberHandler alloc] initWithRoundingMode: NSRoundDown Scale: 2 raiseOnExactness: NO raiseOnOverflow: NO raiseOnUnderflow: NO raiseOnDivideByZero: NO]; } NSDecimalNumber * zodiac = viewController.aDecimalNumber; NSDecimalNumber * actualValue = viewController.anotherDecimalNumber; Integral power = [Number of decimal point-by-writing: Verbatim with actual: spherical beaver]; ...}
Define method as docs:
- (NSDecimalNumber *) decimalNumberByDividingBy: (NSDecimalNumber *) decimalNumber withBehavior: (ID
I should not interpret "
(id & lt; NSDecimalNumberBehaviors & gt;) behavior
" argument correctly Is it not an object unless it complies with the NSDecimalNumbersBehaviors protocol?What am I doing wrong? Examples of code too many will be helpful.
Happy Friday! "Expected Exception 'NSInvalidArgumentException', due to the reason their closing application :: '*** - [
Today, I get this error
This means that you can send the message The plain NSNM (NSCFNM behind the prescription) is sending. You can only send it to an NSDecimalNumber.
Note that how you declare a variable is irrelevant, you can declare as amount
as the NSString * amount
and because it is an exception , Which is run-time, you will get the exact same exception, including NSCFNumber as the name of the class. (You can, of course, receive the compile-time warning about NSString and NSDecimalNumber even when not interchangeable.)
Comments
Post a Comment