I am looking for a way to get (and set) the wallpaper in objective c under Mac OS X.
Do you have code/pointer for this?
Thanks in advance for your help.
Open the System Preferences app. Click on Desktop & Screen Saver. Double click on "Desktop Pictures" on the left side to open the Desktop Pictures folder. Click into this folder when it opens up (alternatively, go to System > Library > Desktop Pictures).
For OSX >= 10.6 use NSWorkSpace
:
-desktopImageURLForScreen:
-setDesktopImageURL:forScreen:options:error:
For a CFPreferences
-based solution see e.g. the topdraw sources:
CFStringRef appID = CFSTR("com.apple.desktop");
CFStringRef bkg = CFSTR("Background");
// get:
NSDictionary *origBackgroundDict = (NSDictionary)CFPreferencesCopyAppValue(bkg, appID);
// ...
// set and notify dock:
CFPreferencesSetAppValue(bkg, (CFPropertyListRef)backgroundDict, appID);
CFPreferencesAppSynchronize(appID);
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"com.apple.desktop" object:@"BackgroundChanged"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With