在OS X v10.11中不推荐使用NSTextView的insertText方法.什么是替代品? [英] NSTextView's insertText method is deprecated in OS X v10.11. What is the replacement?
问题描述
我在AppKit API参考中看到,在OS X v10.11中不推荐使用insertText
方法.我应该用什么代替?
I saw in the AppKit API Reference that the insertText
method is deprecated in OS X v10.11. What am I supposed to use as a replacement?
推荐答案
文档说
- (void)insertText:(id)aString
此方法是用户键入文本输入NSTextView
的方法.有关更多信息,请参见NSInputManager
类和NSTextInput
协议规范.
...
This method is the means by which text typed by the user enters an NSTextView
. See the NSInputManager
class and NSTextInput
protocol specifications for more information.
...
在NSTextInput
中有一个注释:
重要
NSTextInput
协议计划弃用.请使用OS X v10.5中引入的NSTextInputClient
协议,如NSTextInputClient Protocol Reference
中所述.
NSTextInput
protocol is slated for deprecation. Please use NSTextInputClient
protocol, introduced in OS X v10.5, as described in NSTextInputClient Protocol Reference
.
在NSTextInputClient
协议中,有一种方法
- (void)insertText:(id)aString
replacementRange:(NSRange)replacementRange
这似乎是合适的替代品
这篇关于在OS X v10.11中不推荐使用NSTextView的insertText方法.什么是替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!