Instance Method

dataFromRange:documentAttributes:error:

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

Declaration

- (NSData *)dataFromRange:(NSRange)range documentAttributes:(NSDictionary<NSAttributedStringDocumentAttributeKey, id> *)dict error:(NSError * _Nullable *)error;

Parameters

range

The range.

dict

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

error

An in-out variable containing an encountered error, if any.

Return Value

Returns the data for the attributed string, or nil if failure. When nil, error encapsulates the error information.

Discussion

Raises an NSRangeException if any part of range lies beyond the end of the receiver’s characters.

See Also

Generating Data

- fileWrapperFromRange:documentAttributes:error:

Returns an NSFileWrapper object that contains a text stream corresponding to the characters and attributes within the given range.

- docFormatFromRange:documentAttributes:

Returns a data object that contains a Microsoft Word–format stream corresponding to the characters and attributes within the specified range.

- RTFFromRange:documentAttributes:

Returns an NSData object that contains an RTF stream corresponding to the characters and attributes within the given range, omitting all attachment attributes.

- RTFDFromRange:documentAttributes:

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

- RTFDFileWrapperFromRange:documentAttributes:

Returns an NSFileWrapper object that contains an RTFD document corresponding to the characters and attributes within the given range.