Instance Method

runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:

Presents a modal Save panel to the user, then tries to save the document if the user approves the panel.

Declaration

- (void)runModalSavePanelForSaveOperation:(NSSaveOperationType)saveOperation delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo;

Parameters

saveOperation

The type of save operation.

delegate

The delegate to which the selector message is sent.

didSaveSelector

The selector of the message sent to the delegate.

contextInfo

Object passed with the callback to provide any additional context information.

Discussion

When saving is completed, regardless of success or failure, or has been canceled, sends the message selected by didSaveSelector to the delegate, with contextInfo as the last argument. The method selected by didSaveSelector must have the same signature as:

- (void)document:(NSDocument *)doc didSave:(BOOL)didSave contextInfo:(void  *)contextInfo

Invoked from saveDocumentWithDelegate:didSaveSelector:contextInfo:, and from the saveDocumentAs: and saveDocumentTo: action methods. The default implementation of this method first makes sure that any editor registered using the Cocoa Bindings NSEditorRegistration informal protocol has committed its changes, then creates a Save panel, adds a standard file format accessory view (if there is more than one file type for the user to choose from and shouldRunSavePanelWithAccessoryView returns YES), sets various attributes of the panel, invokes prepareSavePanel: to provide an opportunity for customization, then presents the panel. If the user approves the panel, the default implementation sends the message saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:.

For backward binary compatibility with Mac OS v10.3 and earlier, the default implementation of this method instead invokes the deprecated saveToFile:saveOperation:delegate:didSaveSelector:contextInfo: if it is overridden, even if the user cancels the panel.

See Also

Reading From and Writing to Files

readFromFileWrapper:ofType:error:

Sets the contents of this document by reading from a file wrapper of a specified type.

fileModificationDate

The last known modification date of the document’s on-disk representation.

shouldRunSavePanelWithAccessoryView

A Boolean value indicating whether the document’s Save panel displays a list of supported writable document types.

keepBackupFile

A Boolean value indicating whether the document keeps the backup files created before the document data is written to a file.

backupFileURL

The URL for the document’s backup file that was created during an autosave operation.

fileURL

The location of the document’s on-disk representation.

draft

A Boolean value indicating whether the document is a draft that the user has not expressed an interest in keeping around.