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

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

问题描述

我在 AppKit API 参考中看到 insertText 方法在 OS X v10.11 中已被弃用.我应该用什么来代替?

解决方案

文档说

<块引用>

- (void)insertText:(id)aString

此方法是用户键入的文本输入NSTextView 的方法.有关详细信息,请参阅 NSInputManager 类和 NSTextInput 协议规范....

NSTextInput中有一个注释:

<块引用>

重要

NSTextInput 协议将被弃用.请使用 NSTextInputClient 协议,在 OS X v10.5 中引入,如NSTextInputClient 协议参考 中所述.

NSTextInputClient 协议中有一个方法

- (void)insertText:(id)aString替换范围:(NSRange)替换范围

这似乎是合适的替代品

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?

解决方案

The documentation says

- (void)insertText:(id)aString

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. ...

In NSTextInput there is a note:

IMPORTANT

NSTextInput protocol is slated for deprecation. Please use NSTextInputClient protocol, introduced in OS X v10.5, as described in NSTextInputClient Protocol Reference.

In NSTextInputClient protocol there is a method

- (void)insertText:(id)aString
  replacementRange:(NSRange)replacementRange

This seems to be the appropriate replacement

这篇关于NSTextView 的 insertText 方法在 OS X v10.11 中已弃用.什么是替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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