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.
NSTextView has a method -insertText: which does what you want:
[myTextView insertText:@"hello world"];
The method accepts either an NSString or an NSAttributedString.
精彩评论