Returns the shared defaults object.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
Synchronizes any changes made to the shared user defaults object and releases it from memory.
[NSUserDefaults resetStandardUserDefaults];
Returns an NSUserDefaults object initialized with the defaults for the current user account.
NSUserDefaults *userDefaults = [[NSUserDefaults alloc]init];
Adds the contents of the specified dictionary to the registration domain.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults registerDefaults:@{@"User": @"Raj"}];
NSLog(@"%@",[userDefaults objectForKey:@"User"]);
2014-04-16 08:19:11.310 iOS-Tutorial[2688:a0b] Raj
Sets the value of the specified default key to the specified Boolean value.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setBool:YES forKey:@"iOS"];
NSLog(@"%d",[userDefaults boolForKey:@"iOS"]);
2014-04-16 08:22:29.958 iOS-Tutorial[2719:a0b] 1
Sets the value of the specified default key to the specified floating-point value.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setFloat:12.3 forKey:@"iOS"];
NSLog(@"%f",[userDefaults floatForKey:@"iOS"]);
2014-04-16 08:31:59.136 iOS-Tutorial[2784:a0b] 12.300000
Sets the value of the specified default key to the specified integer value.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setInteger:12 forKey:@"iOS"];
NSLog(@"%d",[userDefaults integerForKey:@"iOS"]);
2014-04-16 08:33:25.364 iOS-Tutorial[2796:a0b] 12
Sets the value of the specified default key in the standard application domain.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@[@"Eezy", @"Tut"] forKey:@"iOS"];
NSLog(@"%@",[userDefaults arrayForKey:@"iOS"]);
2014-04-16 08:21:02.083 iOS-Tutorial[2706:a0b] (
Eezy,
Tut
)
Sets the value of the specified default key to the double value.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setDouble:12.5 forKey:@"iOS"];
NSLog(@"%f",[userDefaults doubleForKey:@"iOS"]);
2014-04-16 08:34:31.684 iOS-Tutorial[2809:a0b] 12.500000
Sets the value of the specified default key to the specified URL.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setURL:[NSURL URLWithString:@"http://ios.eezytutorials.com"] forKey:@"iOS"];
NSLog(@"%@",[userDefaults URLForKey:@"iOS"]);
2014-04-16 08:36:34.433 iOS-Tutorial[2824:a0b] http://ios.eezytutorials.com
Returns the array associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@[@"Eezy", @"Tut"] forKey:@"iOS"];
NSLog(@"%@",[userDefaults arrayForKey:@"iOS"]);
2014-04-16 08:21:02.083 iOS-Tutorial[2706:a0b] (
Eezy,
Tut
)
Returns the Boolean value associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setBool:YES forKey:@"iOS"];
NSLog(@"%d",[userDefaults boolForKey:@"iOS"]);
2014-04-16 08:22:29.958 iOS-Tutorial[2719:a0b] 1
Returns the data object associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:[@"Eezy" dataUsingEncoding:NSUTF8StringEncoding] forKey:@"iOS"];
NSLog(@"%@",[userDefaults dataForKey:@"iOS"]);
2014-04-16 08:30:11.560 iOS-Tutorial[2744:a0b] <45657a79>
Returns the dictionary object associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@{@"Eezy" : @"Website"} forKey:@"iOS"];
NSLog(@"%@",[userDefaults dictionaryForKey:@"iOS"]);
2014-04-16 08:31:16.297 iOS-Tutorial[2774:a0b] {
Eezy = Website;
}
Returns the floating-point value associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setFloat:12.3 forKey:@"iOS"];
NSLog(@"%f",[userDefaults floatForKey:@"iOS"]);
2014-04-16 08:31:59.136 iOS-Tutorial[2784:a0b] 12.300000
Returns the integer value associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setInteger:12 forKey:@"iOS"];
NSLog(@"%d",[userDefaults integerForKey:@"iOS"]);
2014-04-16 08:33:25.364 iOS-Tutorial[2796:a0b] 12
Returns the object associated with the first occurrence of the specified default.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@[@"Eezy", @"Tut"] forKey:@"iOS"];
NSLog(@"%@",[userDefaults arrayForKey:@"iOS"]);
2014-04-16 08:21:02.083 iOS-Tutorial[2706:a0b] (
Eezy,
Tut
)
Returns the array of strings associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@[@"Eezy",@"Tuts"] forKey:@"iOS"];
NSLog(@"%@",[userDefaults stringArrayForKey:@"iOS"]);
2014-04-16 08:37:55.046 iOS-Tutorial[2841:a0b] (
Eezy,
Tuts
)
Returns the string associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"Eezy"forKey:@"iOS"];
NSLog(@"%@",[userDefaults stringForKey:@"iOS"]);
2014-04-16 08:38:31.790 iOS-Tutorial[2866:a0b] Eezy
Returns the double value associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setDouble:12.5 forKey:@"iOS"];
NSLog(@"%f",[userDefaults doubleForKey:@"iOS"]);
2014-04-16 08:34:31.684 iOS-Tutorial[2809:a0b] 12.500000
Returns the NSURL instance associated with the specified key.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setURL:[NSURL URLWithString:@"http://ios.eezytutorials.com"] forKey:@"iOS"];
NSLog(@"%@",[userDefaults URLForKey:@"iOS"]);
2014-04-16 08:36:34.433 iOS-Tutorial[2824:a0b] http://ios.eezytutorials.com
Removes the value of the specified default key in the standard application domain.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"Eezy"forKey:@"iOS"];
[userDefaults removeObjectForKey:@"iOS"];
NSLog(@"%@",[userDefaults stringForKey:@"iOS"]);
2014-04-16 08:39:12.559 iOS-Tutorial[2876:a0b] (null)
Writes any modifications to the persistent domains to disk and updates all unmodified persistent domains to what is on disk.
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"Eezy"forKey:@"iOS"];
NSLog(@"%d",[userDefaults synchronize]);
2014-04-16 08:40:10.188 iOS-Tutorial[2900:a0b] 1