I've an NSTextView with with several semi-colon separated strings. I need to find on which of those strings the caret has been placed. How could I do that?
Asked
Active
Viewed 6,908 times
2 Answers
31
NSInteger insertionPoint = [[[myTextView selectedRanges] objectAtIndex:0] rangeValue].location;

Art Gillespie
- 8,747
- 1
- 37
- 34
-
Thank you. This one helped me. :) – Sid Dec 30 '13 at 08:47
3
For Swift 4
let insertionPointIndex = myTextView.selectedRanges.first?.rangeValue.location

Jay Mehta
- 1,511
- 15
- 20