I've implemented a simple drfat storage for UITextView I use in application. Everything works fine, but when I retrieve this draft, assign it to the UITextView and set selectedRange (to also some stored value) I get this weird warning:
requesting caretRectForPosition: with a position beyond the NSTextStorage (4)
From the things I've noticed... This only happens for strings which are shorter than 4 characters (this may give some clue, because 4 also appears in the warning message).
It may be helpful ti post the actual assignment code, so here it is:
self.textView.text = savedDraft.text;
self.textView.selectedRange = NSMakeRange(savedDraft.cursorPosition, 0);
Do you have any idea what can generate this kind of warning? I've found here that this may be caused by Swift implementation of UITextView, but we're pure Objective-C.
Update:
When I save I do save this location as NSUInteger and I get it from my UITextView like this:
self.textView.selectedRange.location
So if you consider a simple "Hi" message (two characters) I get this kind of logs form save and retrieve methods:
Get draft position: 0
Saving draft position: 2
Get draft position: 2
