Instance Method


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


func load(fromContents contents: Any, ofType typeName: String?) throws



An object encapsulating the document data to load. This object is either an instance of the NSData class (for flat files) or the FileWrapper class (for file packages).


The file type of the document, a Uniform Type Identifier (UTI) based on the file extension of fileURL. You can obtain the default value of the file type from the fileType property.


If you cannot load the document data for any reason, return by indirection an NSError object that encapsulates the reasons you can’t. Otherwise, ignore this parameter.

Return Value

true if you successfully load the document, false otherwise.


Override this method to accept and load the data for a document. After UIDocument reads the document data from the file located at fileURL it calls your subclass, passing the data to the subclass in this method. This method is called on the queue that the open(completionHandler:) method was called on (typically, the main queue).

See Also

Reading Document Data

func read(from: URL)

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