Search code examples
objective-ccocoanstextviewnspasteboard

how to copy all attributed content from NSTextView to NSPasteboard


I'm trying to implement auto copy content from NSTextView to clipboard for pasting it in editor in the future. NSTextView has plain and attributed text and images.

If I select all and copy by pressing CMD+C and paste to some rich editor (for example Mail.app) everything is fine.

I found this solution to copy RTF on CocoaDev.com

But when I'm trying to copy my content through this solution is nothing happening if I pasting then in editor.

How to copy attributed text with images from NSTextView textStorage to NSPasteboard?


Solution

  • All that was needed is to use NSRTFDPboardType.