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.
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.
For OSX >= 10.6 use NSWorkSpace
:
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"];