Re: How to access the path of the desktop image
Re: How to access the path of the desktop image
- Subject: Re: How to access the path of the desktop image
- From: "R. Matthew Emerson" <email@hidden>
- Date: Fri, 15 Jun 2007 18:17:46 -0400
On Jun 15, 2007, at 5:44 PM, Gareth Townsend wrote:
I want to open up the desktop image as the default image to be
worked on in
my application.
I was wondering what the easiest way to access the path of the current
desktop image is?
It looks like it's stored in the user defaults.
Run the following command, and it should be fairly obvious.
% defaults read com.apple.desktop Background
I would treat this as an internal implementation detail and assume
that it's possible that future updates from Apple would cause this to
stop working. That said, you can read it with code like this:
#import <Foundation/Foundation.h>
main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults addSuiteNamed:@"com.apple.desktop"];
NSDictionary *d1 = [defaults dictionaryForKey:@"Background"];
NSDictionary *d2 = [d1 valueForKey:@"default"];
NSLog(@"%@", [d2 valueForKey:@"ImageFilePath"]);
[pool release];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden