PDA

View Full Version : how do you declare NSUser defualts




Programmer
Sep 25, 2009, 02:38 PM
i have been trying to declare an NSUserdefualt in my app for a few hours and i am starting to get really frustrated. How do you set the NSUserdefualt up?



MacDonaldsd
Sep 25, 2009, 02:53 PM
I wrote I post on this

http://objcolumnist.com/2009/06/28/nsuserdefaults-preferences/

Darkroom
Sep 25, 2009, 04:31 PM
instead of writing something like the following several times in methods throughout a class:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];


you could simply define it at the beginning of your class:

#define kDefaults [NSUserDefaults standardUserDefaults]

MacDonaldsd
Sep 25, 2009, 04:40 PM
instead of writing something like the following several times in methods throughout a class:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];


you could simply define it at the beginning of your class:

#define kDefaults [NSUserDefaults standardUserDefaults]


True, I don't like using constants like that though :)

Personal choice though.

Programmer
Sep 25, 2009, 10:20 PM
but how do declare the stuff you want to set as your NSUserdefault

Menge
Sep 25, 2009, 10:27 PM
MacDonaldsd posted the answer for this very early in this thread... just read.