Contents

rtfd(from:documentAttributes:)

Returns a data object that contains an RTFD stream corresponding to the characters and attributes within the specified range.

Declaration

func rtfd(from range: NSRange, documentAttributes dict: [NSAttributedString.DocumentAttributeKey : Any] = [:]) -> Data?

Parameters

  • range:

    The range.

  • dict:

    A required dictionary specifying the document attributes. The dictionary contains values from Document Types and must at least contain Documenttype.

Return Value

A data object containing the RTFD stream containing the characters and attributes.

Discussion

Writes the document-level attributes in docAttributes, as explained in RTF Files and Attributed Strings.

Raises an rangeException if any part of aRange 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 setData(_:forType:), with a second argument of NSRTFPboardType.

See Also

Exporting the string as data