[AC-762] Unhanded exception 'NSRangeException' when Undo key is pressed on iOS numeric keyboard
GitHub Issue | n/a |
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-04-06T05:57:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | ios |
Reporter | Goran Krstevski |
Assignee | Ritu Agrawal |
Created | 2014-03-21T12:47:58.000+0000 |
Updated | 2016-03-08T07:37:01.000+0000 |
Description
I have TextArea control which accept only decimal numeric values. Inserted value is validate on 'change' event and if it is not valid then value of TextArea is set to last valid string.
In case when not valid character is inserted and then UNDO key is pressed on numeric iOS keyboard, application crashed with following message:
[ERROR] The application has crashed with an uncaught exception 'NSRangeException'.(check attachment for more info)
Steps to reproduce on Test case :
1. Press on Text area in the middle of the screen in order to change focus on it
2. When keyboard is opened press on some symbol(e.g. "@" ), text area should be empty
3. Press on "Undo" key on keyboard => Application will crash
Attachments
Thanks for attaching the log file but to evaluate further we need a simple runnable test case. Can you please attach the same?
Test case attached.
This appears to be a test case issue. You are using a keyboard that supports only numeric characters. If you type in numeric characters and then undo, everything works fine and there is no crash. If you type in a symbol using your computer as numeric keyboard does not support this character, you are stripping this symbol in test case and setting the numeric value so undo becomes invalid at this point and causes program to malfunction.
But it is not expect application to crash when user accidentally press on a valid buttons on the keyboard.
Can you please explain how the user is going to type a symbol on a numeric keypad?
Please check screenshot in attachment.
Thanks. The issue here is that you are modifying the user entered value dynamically. For example, if a user types "123@" then you are replacing it with "123" and that string is shorter than the user typed string. Undo Manager tries to undo 4 characters and finds only 3 characters and throws out of range exception. You should either not modify the string or replace an undesired character with space.