Re: CFPreferences
Re: CFPreferences
- Subject: Re: CFPreferences
- From: Uli Kusterer <email@hidden>
- Date: Sat, 28 Jan 2006 18:41:29 +0100
Am 28.01.2006 um 00:03 schrieb Alan Smith:
CFStringRef *appID = CFSTR("com.apple.desktop");
CFStringRef *key = CFSTR("ImageFilePath");
myString = (NSString*)CFPreferencesCopyAppValue(appID, key);
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.
One good rule of thumb for CoreFoundation data types: treat "Ref"
as if it meant "pointer". A CFStringRef is equivalent to an
NSString*. So, in your case you're declaring an NSString** when you
say CFStringRef*. Since a pointer to anything is the same size, you
should get away with that, though. Most of these APIs return NIL when
an item doesn't exist, though. Are you sure the key actually exists?
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.
You should really be using the alias. It's a lucky coincidence that
they're also saving the path there, but the alias is more robust.
By the way what is "IIRC"? Alan
"If I Remember Correctly" You can usually google for such
abbreviations to find out what they mean.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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