• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to access the path of the desktop image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to access the path of the desktop image
      • From: Aaron Wallis <email@hidden>
References: 
 >How to access the path of the desktop image (From: "Gareth Townsend" <email@hidden>)

  • Prev by Date: Re: Foreign Characters
  • Next by Date: Radio Buttons in NSTableView
  • Previous by thread: How to access the path of the desktop image
  • Next by thread: Re: How to access the path of the desktop image
  • Index(es):
    • Date
    • Thread