Re: CFPreferences
Re: CFPreferences
- Subject: Re: CFPreferences
- From: Rosyna <email@hidden>
- Date: Sat, 28 Jan 2006 08:57:39 -0700
make a deep mutable copy (not a normal one, but a deep one) of the
top dictionary then change the values and set the top dictionary back
to the preferences. however, writing is especially dangerous as it
isn't your preference file and the format isn't exactly documented.
Also, it may look at the Alias (as it should) before it even bothers
to look at the path (which should never actually be queried). In
which case you'd have to update the alias data, even though the
format is known today, it is not documented and may change in the
future.
http://developer.apple.com/samplecode/DeskPictAppDockMenu/listing3.html
has *real* sample code for setting the desktop picture, however it
also contains a warning about not being future proof.
Ack, at 1/28/06, Alan Smith said:
Oh, yeah. How would you save the preference back inside the two dictionarys?
Thanks, Alan
On 1/27/06, Rosyna <<mailto:email@hidden> email@hidden> wrote:
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.
}
--
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