views:

40

answers:

1

How would I do this using Objective C and cocoa using Xcode? I am trying to insert a string at the cursor or user selection on the click of a button.

+4  A: 

NSTextView has a method -insertText: which does what you want:

[myTextView insertText:@"hello world"];

The method accepts either an NSString or an NSAttributedString.

dwineman