Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTextView's insertText method is deprecated in OS X v10.11. What is the replacement?

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?

like image 523
beeb Avatar asked Mar 15 '23 16:03

beeb


1 Answers

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

like image 152
vadian Avatar answered Apr 06 '23 23:04

vadian