I’m trying to set an image from reading a plist. I’m working on an app which uses the current desktop wallpaper and sets it as the windows background image. The files is located ~/Library/Preferences/com.apple.desktop.plist
How do I read a key from it? The specific keys i’m trying to read are;
NewImageFilePath
ImageFilePath
I have tried this code which is like reading a plist on the iPhone but it didnt work.
NSString *plistPath = @"~/Library/Preferences/com.apple.desktop.plist";
NSDictionary *plistData = [[NSDictionary dictionaryWithContentsOfFile:plistPath] retain];
NSString *item = [plistData objectForKey:@"NewImageFilePath"];
NSLog([NSString stringWithFormat:@"%@", item]);
Once I can get the actual data located in the plists string my plan is to set it to an NSImageView or to the [window setBackgroundColor:[color]]; method
Thanks in advance.
Note that some info on desktop images can be obtained via public APIS, starting from 10.6. Read
NSWorkspacedocumentation, in particular-[NSWorkspace desktopImageOptionsForScreen:]and such.