Instance Method

saveValuesAndReturnError:

Verifies that the pane’s settings are valid and have been saved.

Declaration

- (BOOL)saveValuesAndReturnError:(NSError * _Nullable *)error;

Parameters

error

If an error occurs, in addition to returning NO you may use this parameter to return information to further describe the error. If you elect to do so, you should create an error object and use it to pass back the error information.

Return Value

YES if the current settings are valid and have been saved; otherwise, NO. If you return NO, the printing system takes no further action and continues to display your pane in the dialog.

Discussion

The printing system invokes this method when your custom pane is visible and the user selects a different pane, dismisses the dialog (other than via cancel), or requests that a preset be saved.

In this required method, you should check the user's input, handle any final interaction with the user, and verify that the pane’s user interface settings and internal settings have been saved. If you need more interaction with the user, perhaps because some of the input values were invalid, you should return NO. Returning YES indicates that the input values have been validated and saved, and the printing system can allow the user to show another pane or dismiss the dialog.

A pane’s user interface settings are based on values stored in printing system objects associated with the current print job. To provide access to these printing system objects, the printing system creates a host object that conforms to the PDEPlugInCallbackProtocol informal protocol. The printing system passes the host object to your PDE when it sends the PDEPanelsForType:withHostInfo: message, a method in the PDEPlugIn informal protocol. Your PDE is responsible for making this host object available to its panes.

Panes use several different mechanisms for saving their settings or options:

  • If the user changes a PPD option, your pane should save the option’s new value immediately by sending the willChangePPDOptionKeyValue:ppdChoice: message to the host object.

  • If the user changes a custom option, your pane should save the option’s new value in the host object’s PMPrintSettings or PMPageFormat object. You can save the value immediately when the user changes the option, or wait until this method is invoked.