Insert a line of text in an NSTextView at the cursor position or select text using Objective-C

How do I do this using Objective-C and cocoa using Xcode? I am trying to insert a line into a cursor or user selection with the click of a button.

0
source share
1 answer

There is a -insertText method in NSTextView: it does what you want:

[myTextView insertText:@"hello world"];

The method accepts either NSString or NSAttributedString.

+5
source

All Articles