How to do to get the selected string from a NSTextView in Swift?
// create a range of selected text let range = mainTextField.selectedRange() // this works but I need a plain string not an attributed string let str = mainTextField.textStorage?.attributedSubstring(from: range) Maybe I have to add an intermediate step where I get the full string and then apply the range on it?