How can I set an NSTextView
to an NSAttributedString
? I do not want to use a textConainer, and I tried:
[myTextView insertText:myMutableAttributedString];
but it didn't work. Nothing happened...not even a warning or a runtime error. Any help would be appreciated.
Textview must be editable to insert.
[myTextView setEditable:YES];
[myTextView insertText:myMutableAttributedString];
[myTextView setEditable:NO];
In Swift 2.2:
myTextView.textStorage?.setAttributedString(myMutableAttributedString)
In Objective-C:
[[myTextView textStorage] setAttributedString:myMutableAttributedString];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With