从NSTextView Objective-C获取选择(突出显示的文本)字符串 [英] Get selection (highlighted text) string from NSTextView Objective-C
本文介绍了从NSTextView Objective-C获取选择(突出显示的文本)字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从NSTextView
作为NSString
获取所选文本的字符串?
How can I get the selected text's string from a NSTextView
as an NSString
?
非常感谢您的帮助.
推荐答案
Since NSTextView is a subclass of NSText, you can use NSText instance methods to figure out the selected string like so:
NSString *selected = [[myTextView string]
substringWithRange:[myTextView selectedRange]];
这篇关于从NSTextView Objective-C获取选择(突出显示的文本)字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文