Instance Method


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


- (BOOL)readFromURL:(NSURL *)url options:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)opts documentAttributes:(NSDictionary<NSAttributedStringDocumentAttributeKey, id> * _Nullable *)dict error:(NSError * _Nullable *)error;



The URL of the file to read.


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


On return, contains the document attributes. For a list of possible values, see “Document Attributes” in NSAttributedString.


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

YES if the attributed string is created successfully or NO if it was not.


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

- readFromData:options:documentAttributes:error:

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