How to set the desktop image to NSWindow Background image in mac os application programatically. Suppose if I click a button then whatever the desktop image is there it should apply to NSWindow Background.
To obtain a screen's desktop image you use methods provided by NSWorkspace
.
The method desktopImageURLForScreen:
returns a URL for the image file, while the method desktopImageOptionsForScreen:
returns a dictionary of desktop image options - how images should be scaled, whether they should be tiled, etc.
Using those methods and an NSImageView
you should be able to display the desktop image appropriately scaled, tiled and aligned as a window background. If you are supporting windows spanning screens on multi-screen systems it will be a bit more involved but the method is essentially the same.
HTH