在OS X v10.11中不推荐使用NSTextView的insertText方法.什么是替代品? [英] NSTextView's insertText method is deprecated in OS X v10.11. What is the replacement?

查看:86
本文介绍了在OS X v10.11中不推荐使用NSTextView的insertText方法.什么是替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆