Contents

read(from:options:documentAttributes:)

Sets the contents of attributed string using the contents of the specified file.

Declaration

func read(from url: URL, options opts: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?) throws
func read(from url: URL, options opts: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer<NSDictionary?>?, error: ()) throws

Parameters

  • url:

    The URL of the file to read.

  • opts:

    The option keys for importing the document. For a list of possible values, see “Option keys for importing documents” in Nsattributedstring.

  • dict:

    On return, contains the document 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.

Discussion

Filter services can be used to convert the contents of the URL into a format recognized by Cocoa.

For RTF formatted files, the contents of the file are appended to the previous string instead of replacing the previous string. Therefore, when using this method with existing content it’s best to clear the content away explicitly.

See Also

Reading Content