Instance Method

read(from:ofType:)

Sets the contents of this document by reading from data of a specified type and returns true if successful.

Declaration

func read(from data: Data, ofType typeName: String) throws

Parameters

data

The data object from which the document contents are read.

typeName

The string that identifies the document type.

outError

On return, if the document contents could not be read, a pointer to an error object that encapsulates the reason they could not be read.

Return Value

true if the document contents could be read; otherwise, false.

Discussion

The default implementation of this method throws an exception because at least one of the three reading methods (this method, read(from:ofType:), read(from:ofType:)), or every method that may invoke read(from:ofType:), must be overridden.

See Also

Loading Document Data

func data(ofType: String) -> Data

Creates and returns a data object that contains the contents of the document, formatted to a specified type.

func fileWrapper(ofType: String) -> FileWrapper

Creates and returns a file wrapper that contains the contents of the document, formatted to the specified type.

var isEntireFileLoaded: Bool

A Boolean value indicating whether the document’s file is completely loaded into memory.