Re: CFPreferences
Re: CFPreferences
- Subject: Re: CFPreferences
- From: Alan Smith <email@hidden>
- Date: Fri, 27 Jan 2006 18:03:58 -0500
>> ´to get an NSString is typecast it. If the return value in your case
>> is a CFStringRef, you can just cast to NSString *. If it's some other
>> plist type, cast to the appropriate class. If you're not sure what
>> type you have, you can use CFGetTypeID (or just debug the app and use
>> "po").
>IIRC, that's actually an alias stores as an NSData in this particular
>case, so it isn't at all surprising if it's hard to get a string out
>of this. Use NDAlias or BDAlias to turn that back into an alias and
>extract an NSString with a path from that.
>One suggestion for the future: You can edit nearly all the
>preferences files in (~)/Library/Preferences/ using Property List
>Editor.app, which will also show you their hierarchy and data types.
>Cheers
Thanks guys, but it's not working. I did type cast it like Tom said, but
when I watch through the debugger it, changes my variable to nil. Here's the
code:
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?
By the way what is "IIRC"? Alan
_______________________________________________
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