The NSRTFDPboardType
is used for the contents of an RTFD file package (a directory containing an RTF text file and one or many image files). There are several ways to work with RTFD data. If you have an NSFileWrapper
object that represents an RTFD file wrapper, you can send it a serializedRepresentation
message to return the RTFD data and write that to the pasteboard as follows:
NSFileWrapper *tempRTFDData = [[[NSFileWrapper alloc] |
initWithPath:@"/tmp/MyTemporaryRTFDDocument.rtfd"] autorelease]; |
[pboard setData:[tempRTFDData serializedRepresentation] |
forType:NSRTFDPboardType]; |
In addition to NSFileWrapper
, instances of classes such as NSAttributedString
and NSText
can return RTFD data. If you are using one of these classes, you can write an RTFD representation of their contents to the pasteboard as follows:
NSAttributedString *attrString = /* get an attributed string */; |
NSRange wholeStringRange = NSMakeRange(0, [attrString length]); |
NSData *rtfdData = [attrString RTFDFromRange:wholeStringRange |
documentAttributes:nil]; |
[pboard setData:rtfdData forType:NSRTFDPboardType]; |
Note that the NSText
method does not require the documentAttributes
parameter.
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-13)