Invalid parameter not satisfying: pos Crash on iOS 15 while pasting text onto UITextView

Varun Tomar
2 min readNov 23, 2021

We were getting a strange crash on iOS 15 while pasting text in UITextView, things working fine on previous iOS version. It’s a bit wired but it’s happening, we had no clue how to fix this iOS 15 specific issue🤯🤯. We approached from here as below :

We went through UITextPasteDelegate documentation and got a hint for a workaround. We got our sight 👀 on a function and it’s comment was our life saver.

- (UITextRange*)textPasteConfigurationSupporting:(id<UITextPasteConfigurationSupporting>)textPasteConfigurationSupporting performPasteOfAttributedString:(NSAttributedString*)attributedString toRange:(UITextRange*)textRange

If this is not implemented, the standard paste mechanism will be used — Means if we have implementation of this method then standard paste mechanism would not happen.

So, we have to confirm UITextPasteDelegate and define this function to avoid standard paste mechanism and make our own. Below are the two definitions we can go for :

Make sure to set UITextPasteDelegate to your UITextView controller

Both the approaches would work 😎😎. You can also do any modifications with these definitions as per your need.

Hope you enjoyed this article. Thanks for reading this🙏🙏. Any feedback in the comment section would be appreciated. If you feel , please share and add some claps 👏 👏 .

You can follow me for fresh articles.

--

--