O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSUserDefaults — Mac OS X 10.0

Synopsis

This class is the entry-point into Mac OS X’s user defaults database, which is how user preferences are stored and managed for applications. Instances of this class are created using the class method standardUserDefaults. This class provides methods for storing and accessing arrays, dictionaries, strings, objects, numbers, and data in an application’s user defaults database.

image with no caption

@interface NSUserDefaults : NSObject
                                  // Initializers
   - (id)init;
   - (id)initWithUser:(NSString *)username;
                                  // Accessor Methods
   - (void)setInteger:(int)value 
                                 forKey:(NSString *)defaultName;
   - (void)setVolatileDomain:(NSDictionary *)domain 
                                 forName:(NSString *)domainName;
   - (void)setBool:(BOOL)value 
                                 forKey:(NSString *)defaultName;
   - (void)setFloat:(float)value 
                                 forKey:(NSString *)defaultName;
   - (void)setObject:(id)value 
                                 forKey:(NSString *)defaultName;
   - (void)setPersistentDomain:(NSDictionary *)domain 
                                 forName:(NSString *)domainName;
                                  // Class Methods
   + (void)resetStandardUserDefaults;
   + (NSUserDefaults *)standardUserDefaults;
                                  // Instance Methods
   - (void)addSuiteNamed:(NSString *)suiteName;
   - (NSArray *)arrayForKey:(NSString *)defaultName;
   - (BOOL)boolForKey:(NSString *)defaultName;
   - (NSData *)dataForKey:(NSString *)defaultName;
   - (NSDictionary *)dictionaryForKey:(NSString *)defaultName;
   - (NSDictionary *)dictionaryRepresentation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required