我試圖把我有的NSDecimalNumber乘以1.1。需要NSDecimalNumber的幫助
我有這個,但它不工作:
NSDecimalNumber *multipy = [NSDecimalNumber decimalNumberWithMantissa:1.1 exponent:0 isNegative:NO];
NSDecimalNumber *savings = [totalExpenses decimalNumberByMultiplyingBy:multipy];
更新:
這裏是整個代碼,沒有人知道爲什麼它不工作?
NSDecimalNumber *totalExpenses = [[event.housePayment decimalNumberByAdding:event.carPayment] decimalNumberByAdding:event.loanPayment];
NSDecimalNumber *multiply = [NSDecimalNumber decimalNumberWithMantissa:11 exponent:-1 isNegative:NO];
NSDecimalNumber *savings = [totalExpenses decimalNumberByMultiplyingBy:multiply];
崩潰在乘行,出現錯誤:*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell decimalNumberByMultiplyingBy:]: unrecognized selector sent to instance 0x5d91a60'
你得到了什麼消息,當它崩潰? –
我剛發佈了消息 – Jon
什麼是'event.housePayment' - 你確定它是一個'NSDecimalNumber'嗎?您還沒有向我們展示過其他代碼行嗎? –