将NSAttributedString复制到粘贴板 [英] Copy NSAttributedString to pasteboard
问题描述
全新的Cocoa和我试图找出如何复制NSAttributedString到粘贴板。
这里是我必须复制一个常规的NSString:
NSPasteboard * pb = [NSPasteboard generalPasteboard];
NSArray * types = [NSArray arrayWithObjects:NSStringPboardType,nil];
[pb declareTypes:types owner:self];
[pb setString:@asdfasdfforType:NSStringPboardType];
如何设置NSAttributedString?
感谢
您想要NSRTFPboardType或NSRTFDPboardType以及NSAttributedString的 Brand new to Cocoa and I'm trying to figure out how to copy an NSAttributedString to the pasteboard. I've looked in the docs and not sure if I'm supposed to use a NSPasteboardItem or not. Here's what I have to copy a regular NSString: How do I set a NSAttributedString? Thanks You want either NSRTFPboardType or NSRTFDPboardType along with the NSAttributedString's 这篇关于将NSAttributedString复制到粘贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! RTFFromRange:documentAttributes:$ c / c> code> /
RTFDFromRange:documentAttributes:
和 setData
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [NSArray arrayWithObjects:NSStringPboardType, nil];
[pb declareTypes:types owner:self];
[pb setString:@"asdfasdf" forType:NSStringPboardType];
RTFFromRange:documentAttributes:
/RTFDFromRange:documentAttributes:
and setData
on the pasteboard.