Instance Method

initForURL:withContentsOfURL:ofType:error:

Initializes a document with the specified contents, and places the resulting document's file at the designated location.

Declaration

- (instancetype)initForURL:(NSURL *)urlOrNil withContentsOfURL:(NSURL *)contentsURL ofType:(NSString *)typeName error:(NSError * _Nullable *)outError;

Parameters

absoluteDocumentURL

The location for the document's file. This value is nil for an autosaved document that the user never explicitly saved.

absoluteDocumentContentsURL

The URL of the file that contains the document's contents. When loading an autosaved document, this URL contains the location of the autosave file. The contents of this file replace the contents of the file in absoluteDocumentURL.

typeName

The string that identifies the document type.

outError

On return, if initialization is unsuccessful, a pointer to an error object that encapsulates the reason the document could not be created.

Return Value

The initialized document object, or nil if the document could not be created.

Discussion

The system calls this method to open a document that has an associated autosave file . You can override this method to handle any document initialization specific to autosave contents.

After reading the contents from the specified autosave file, this method updates the document's change count using the NSChangeReadOtherContents change type.

See Also

Creating a Document Object

- init

Initializes and returns an empty document object.

- initWithContentsOfURL:ofType:error:

Initializes a document located by a URL of a specified type.

- initWithType:error:

Initializes a document of a specified type.