Reputation: 303
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?
Upvotes: 7
Views: 3705
Reputation: 547
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.
Upvotes: 9