Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminating app due to "Range or index out of bounds" exception #84

Closed
1 task done
CFIFok opened this issue Apr 17, 2020 · 6 comments
Closed
1 task done

Terminating app due to "Range or index out of bounds" exception #84

CFIFok opened this issue Apr 17, 2020 · 6 comments

Comments

@CFIFok
Copy link

CFIFok commented Apr 17, 2020

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • read our Wiki;
    • read the entire Known issues section;
    • checked that my issue isn't already filled;
    • searched StackOverflow's input-mask tag for similar problems.

Describe the bug

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString replaceCharactersInRange:withString:]: Range or index out of bounds' in MaskedTextFieldDelegate.swift class.

Steps to reproduce the behaviour:

  1. Create an instance of UITextField with default properties, listener (MaskedTextFieldDelegateListener) and delegate (MaskedTextFieldDelegate)
    1.1. The delegate should be an instance with primaryFormat: "[000000]"(for example [000000], but it can be either [00] or [000] etc.). The main point is that it should have some kind of symbols limitation.
  2. Copy more than 6 symbols in clipboard (depend on the number of zeros in the format [000000]).
  3. Run the application and navigate to the our UITextField.
  4. Perform *three-finger gesture on the UITextField and tap Paste button (Screenshot 1) twice. The size limit should be exceeded, but everything will be ok.
  5. And finally press the Undo button (Screenshot 1).
  6. Crash!

I have made some analysis of this issue and draw conclusions which are depicted on Screenshot 2. Thank you for your cooperation in advance.

Expected behaviour
The delegate should perform the undo operation, if possible, otherwise make nothing.

Actual behaviour
Terminating app due to "Range or index out of bounds" exception.

Screenshots
Screenshot 1
IMG_001
Screenshot 2
IMG_002

Platform information

  • OS version: iOS 13.0+
  • Library version: 6.0
  • Language: Swift 5.0
  • Device (if bug is device-specific): iPhone7\8\X

Additional context
*iOS provides built-in gestures for undo, redo, copy, and paste in text views, triggered using a variety of three-finger moves – swiping left and right, or pinching in or out respectively: https://www.apple.com/ios/ios-13/features/

@taflanidi
Copy link
Collaborator

Hey @CFIFok!
Thanks a lot for you heaven-of-a-detailed cool report, things like this massively assist with debugging.

Speaking of which, we'll have an update this week with a few tweaks, and I'd like to include the fix for this bug as well.

@taflanidi taflanidi added the bug label Apr 20, 2020
@alkincakiralar1996
Copy link

Any updates ?

@taflanidi
Copy link
Collaborator

Update is coming in 7.2.0 :D

That's a marvelous catch, thank you so much!

@taflanidi
Copy link
Collaborator

@CFIFok mind if I add you to our contributors?

@taflanidi
Copy link
Collaborator

Meet 7.2.0.

@alexander-kurilovich-gismart

@taflanidi yep sure! Thanx a lot too 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants