Instance Method

setDesktopImageURL:forScreen:options:error:

Sets the desktop image for the given screen to the image at the specified URL.

Declaration

- (BOOL)setDesktopImageURL:(NSURL *)url forScreen:(NSScreen *)screen options:(NSDictionary<NSWorkspaceDesktopImageOptionKey, id> *)options error:(NSError * _Nullable *)error;

Parameters

url

A file URL to the image. The URL must not be nil.

screen

The screen to set the desktop image on.

options

The options dictionary may contain any of the Desktop Image Dictionary Keys keys, which control how the image is scaled on the screen.

error

A error that is returned by-reference if setting the image fails.

Return Value

YES if the image was set as the desktop, otherwise NO. If NO is returned, the error parameter provides additional information.

Discussion

You should not present a user interface for picking the options. Instead, choose appropriate defaults and allow the user to adjust them in the System Preference Pane.

You must call this method from your app’s main thread.

See Also

Managing the Desktop Image

- desktopImageURLForScreen:

Returns the URL for the desktop image for the given screen.

- desktopImageOptionsForScreen:

Returns the desktop image options for the given screen.

NSWorkspaceDesktopImageOptionKey

The following keys may be specified or returned in the options dictionary for setDesktopImageURL:forScreen:options:error:.