Blank field user types character crash
dulbrich opened this issue · 3 comments
If you have a blank BKCurrencyTextField and you try and type or paste a letter character rather than a number character it crashes the app.
Here's the error:
2016-03-16 15:34:32.494 Alder[68142:1267089] *** Terminating app due to uncaught exception 'NSDecimalNumberOverflowException', reason: 'NSDecimalNumber overflow exception'
0 CoreFoundation 0x0000000107d54e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001077cddeb objc_exception_throw + 48
2 CoreFoundation 0x0000000107d54d9d +[NSException raise:format:] + 205
3 Foundation 0x000000010747db48 -[NSDecimalNumberHandler exceptionDuringOperation:error:leftOperand:rightOperand:] + 193
4 Foundation 0x000000010747c976 _checkErrorAndRound + 65
5 Foundation 0x000000010747cd46 -[NSDecimalNumber decimalNumberByDividingBy:withBehavior:] + 159
6 BKMoneyKit 0x00000001062e06ba -[BKCurrencyTextField textField:shouldChangeCharactersInRange:replacementString:] + 1370
Hi, I found the same issue, I create a fix in BKCurrencyTextField.m in line 67, Its a workaround, but solve my problem.
if (self.numberFormatter.maximumFractionDigits > 0) {
if ([decimalNumber isEqualToNumber:[NSDecimalNumber notANumber]]) {
decimalNumber = 0;
}else{
decimalNumber = [decimalNumber decimalNumberByDividingBy:[NSDecimalNumber decimalNumberWithMantissa:1 exponent:self.numberFormatter.maximumFractionDigits isNegative:NO]];
}
}
Terminate block
If you have a blank BKCurrencyTextField and you try and type or paste a letter character rather than a number character it crashes the app.
Here's the error:
2016-03-16 15:34:32.494 Alder[68142:1267089] *** Terminating app due to uncaught exception 'NSDecimalNumberOverflowException', reason: 'NSDecimalNumber overflow exception'
0 CoreFoundation 0x0000000107d54e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001077cddeb objc_exception_throw + 48
2 CoreFoundation 0x0000000107d54d9d +[NSException raise:format:] + 205
3 Foundation 0x000000010747db48 -[NSDecimalNumberHandler exceptionDuringOperation:error:leftOperand:rightOperand:] + 193
4 Foundation 0x000000010747c976 _checkErrorAndRound + 65
5 Foundation 0x000000010747cd46 -[NSDecimalNumber decimalNumberByDividingBy:withBehavior:] + 159
6 BKMoneyKit 0x00000001062e06ba -[BKCurrencyTextField textField:shouldChangeCharactersInRange:replacementString:] + 1370
Disable / terminate code