Instance Method

load(fromContents:ofType:)

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

Declaration

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

Parameters

contents

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).

typeName

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.

outError

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.

Discussion

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

Related Symbols