Instance Method

writeToURL:ofType:forSaveOperation:originalContentsURL:error:

Saves changes in the document’s managed object context and saves the document’s persistent store to a given URL.

Declaration

- (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation originalContentsURL:(NSURL *)absoluteOriginalContentsURL error:(NSError * _Nullable *)error;

Parameters

absoluteURL

An URL that specifies the new location for the document store. It must not be a relative URL.

typeName

The document type.

saveOperation

The save operation type. See the "Constants" section in NSDocument for possible values.

absoluteOriginalContentsURL

An URL that specifies the location of the original document store.

error

If the save fails to complete correctly, upon return contains an NSError object that describes the problem.

Return Value

YES if the save completes correctly, otherwise NO.

Discussion

See Also

Document Content Management

- readFromURL:ofType:error:

Sets the contents of the receiver by reading from a file of a given type located by a given URL.

- revertToContentsOfURL:ofType:error:

Overridden to clean up the managed object context and controllers during a revert.