Re: User preferences

Adam Fedor <[email protected]>
Newsgroups gmane.comp.lib.gnustep.user
Message-ID <[email protected]>
On Dec 15, 2004, at 4:50 PM, Samuel Hornus wrote:
> http://developer.apple.com/documentation/Cocoa/Conceptual/ 
> UserDefaults/Tasks/UsingDefaults.html#//apple_ref/doc/uid/20000719
>
> Needless to say, it does not work. I kinda feel that I may need to
> supply some "default domain name" to the NSUserDefaults, but I can't  
> see
> where/what/when/why/...
>
> Do you have some clues about saving some prefs and retrieving them ?
> What need be added to the code examplified in the webpage above ?
> Thank you in advance !
>

I'm not sure what it says there but this should work:

   NSUserDefaults *defs;

   defs = [NSUserDefaults standardUserDefaults];
   str = @"Messy";
   [defs setObject: str forKey: @"UserTidyness"];

and to retrieve:

   defs = [NSUserDefaults standardUserDefaults];
   str = [defs objectForKey: @"UserTidyness"];

There's probably something wrong if it doesn't work.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.