Instance Method


Reads the document data in a file at a specified location in the application sandbox.


func read(from url: URL) throws



A file URL that identifies the location of the document file in the application sandbox. This file URL is typically the one returned by the fileURL property.


If the document file cannot be read, returns by indirection an error object that encapsulates the reasons why the read operation failed.

Return Value

true if the read operation succeeds, otherwise false.


Typical UIDocument subclasses should not need to call this method directly, especially if the entire file is read at once. The default implementation calls load(fromContents:ofType:) on the queue on which open(completionHandler:) was called to provide the UIDocument subclass with the document data object.

Subclasses that want more control over the reading of the document file—for example, that want to read a large document file incrementally—can override this method. It is not necessary for these subclasses to call the superclass implementation (super).

See Also

Reading Document Data

func open(completionHandler: ((Bool) -> Void)?)

Opens a document asynchronously.

func load(fromContents: Any, ofType: String?)

Override this method to load the document data into the app’s data model.