• 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: CFPreferences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFPreferences


  • Subject: Re: CFPreferences
  • From: Rosyna <email@hidden>
  • Date: Fri, 27 Jan 2006 16:16:46 -0700

Because ImageFilePath isn't in the top of the preferences. It is inside a dictionary with some weird number (or default) which is inside a dictionary called "Background". You must go through both of those.

NSDictionary* background=(NSDictionary*)CFPreferencesCopyAppValue(CFSTR("com.apple.desktop"), CFSTR("Background"));

if (background and CFDictionaryGetTypeID()==CFGetTypeID((CFTypeRef)background))
{
NSDictionary* thingy=[background objectForKey:@"default"];
if (thingy and CFDictionaryGetTypeID()==CFGetTypeID((CFTypeRef)thingy))
{
NSString* pathsAreEvilAndShouldNeverBeUsedForAnthing=[thingy objectForKey:@"ImageFilePath"];
if (pathsAreEvilAndShouldNeverBeUsedForAnthing and CFDictionaryGetTypeID()==CFGetTypeID((CFTypeRef) pathsAreEvilAndShouldNeverBeUsedForAnthing))
{


// do whatever with the path or retain it for later.
}
}
[background release]; //releases the path unless you explicitly retained the path above.
}


Ack, at 1/27/06, Alan Smith said:

NSString *myString;

CFStringRef *appID = CFSTR("com.apple.desktop");
CFStringRef *key = CFSTR("ImageFilePath");

myString = (NSString*)CFPreferencesCopyAppValue(appID, key);

NSLog(myString);

Now that looks simple enough but I can't get it to work. Now when I watch it
through the debugger the CF variables are set right and turn red (like
they're supossed to), then it gets to initializing myString and it turns red
but is set to nil.
Now if you were to look in your com.apple.desktop.plist file, you could
find, key, ImageFilePath, and its data would be something like,
"/Library/User Pictures/Aqua Blue.jpg". Contrary to what Uli said it's a
string. I looked in Property List Editor.app and it says the class for the
key is string, but the key above that is ImageFileAlias which is of type
alias.
So the question is, what's going on?

--


Sincerely, Rosyna Keller Technical Support/Holy Knight/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CFPreferences{spam?}
      • From: Darkshadow <email@hidden>
    • Re: CFPreferences
      • From: Rosyna <email@hidden>
References: 
 >Re: CFPreferences (From: Alan Smith <email@hidden>)

  • Prev by Date: Re: CFPreferences
  • Next by Date: Re: How to select the next field?
  • Previous by thread: Re: CFPreferences
  • Next by thread: Re: CFPreferences
  • Index(es):
    • Date
    • Thread