我正在尝试从用户默认值中检索一个数字并将其相乘。这是我的代码:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSDecimalNumber *current = [prefs objectForKey:@"account"];
NSDecimalNumber *multiplier = [NSDecimalNumber decimalNumberWithString:@"1.15"];
NSDecimalNumber *floo = [current decimalNumberByMultiplyingBy: multiplier];
它一上线就给了我这个非常可怕的崩溃floo
。大量错误 gobbledygook 开始于:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFNumber decimalNumberByMultiplyingBy:]: unrecognized selector
sent to instance 0x8c7b1e0'
这似乎是一件非常简单的事情,但我的天哪!发生了什么?