开发者

Insert a string of text into an NSTextView at the cursor position or selection of text using Objective C

开发者 https://www.devze.com 2023-01-22 11:04 出处:网络
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 -insertTex

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号