I am using this code to get the cursor position:
NSInteger insertionPoint = [[[myTextView selectedRanges] objectAtIndex:0] rangeValue].location;
How to add selected text at the current cursor position and not by appending the text?
If I understand your problem correctly, this will work for you:
[textView setSelectedRange:NSMakeRange(4, 0)];
[textView insertText:@"my copied text"];
In the NSMakeRange()
4 is the location in the text view and 0 is used for the length because you don't want to replace any text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With