• 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: 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
References: 
 >Re: CFPreferences (From: Alan Smith <email@hidden>)

  • Prev by Date: Re: CFPreferences
  • Next by Date: Re: Graph/Chart UI widgets
  • Previous by thread: Re: CFPreferences
  • Next by thread: Re: CFPreferences
  • Index(es):
    • Date
    • Thread