Returns an NSData
object that contains an RTF stream corresponding to the characters and attributes within the given range, omitting all attachment attributes.
SDK
- macOS 10.0+
Framework
- App
Kit
Declaration
- (NSData *)RTFFromRange:(NSRange)range documentAttributes:(NSDictionary<NSAttributed String Document Attribute Key, id> *)dict;
Parameters
aRange
The range.
docAttributes
A required dictionary specifying the document attributes. The dictionary contains values from Document Types and must at least contain
NSDocument
.Type Document Attribute
Return Value
A data object containing an RTF stream for the attributed string.
Discussion
Writes the document-level attributes in doc
, as explained in RTF Files and Attributed Strings.
Raises an NSRange
if any part of a
lies beyond the end of the receiver’s characters.
When writing data to the pasteboard, you can use the NSData
object as the first argument to the NSPasteboard
method set
, with a second argument of NSRTFPboard
. Although this method strips attachments, it leaves the attachment characters in the text itself. The NSText
method RTFFrom
, on the other hand, does strip attachment characters when extracting RTF.