Instance Method

initForURL:withContentsOfURL:ofType:error:

Initializes a document located by a URL of a specified type, but by reading the contents for the document from a different URL.

Declaration

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

Parameters

absoluteDocumentURL

The URL where the document is located.

absoluteDocumentContentsURL

The URL from which the contents of the document are obtained.

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 NSDocument object, or, if the document could not be created, nil.

Discussion

The absoluteDocumentURL argument is nil if the initializing is part of the reopening of an autosaved document when the autosaved document was never explicitly saved.

During reopening of autosaved documents, this method uses the following NSDocumentChangeType constant to indicate that an autosaved document is being reopened:

NSChangeReadOtherContents

See Also

Initializing

- init

Initializes and returns an empty NSDocument object.

- initWithContentsOfURL:ofType:error:

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

- initWithType:error:

Initializes a document of a specified type.