Instance Method

read(from:options:documentAttributes:error:)

Sets the contents of the receiver from the stream at data.

Declaration

iOS, Mac Catalyst, tvOS, watchOS
func read(from data: Data, options opts: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?) throws
macOS
func read(from data: Data, options opts: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?, error: ()) throws

Parameters

data

The data object providing text data.

opts

Keys specifying the types of documents and other document import options. For a list of possible values, see “Option keys for importing documents” in NSAttributedString

dict

On return, the dictionary (if provided) contains keys representing various document-wide attributes. For a list of possible values, see “Document Attributes” in NSAttributedString.

error

Upon return, if an error occurs, contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL.

Return Value

true if the attributed string is created successfully; otherwise false.

Discussion

opts can contain one of the values described in the Constants section of NSAttributedString Application Kit Additions Reference ("Option keys for importing documents").

On return, the documentAttributes dictionary (if provided) contains the various keys described in the Constants section of NSAttributedString Application Kit Additions Reference. If unsuccessful, returns NO , after setting error to point to an NSError object that encapsulates the reason why the attributed string object could not be created.