I have a NSTextView and I need to check if there is a selection, (blue highlight) of a word (or anything really), and not just a cursor. How can I do this. nil
doesn't work, and I can't figure it out.
You can use [NSTextView selectedRanges]
method to see if there is a selection.
if (self.textView.selectedRanges.count > 0) {
NSLog(@"Some text is selected!");
}
You may want to read the documentation for more information.