NSUserDefaults数据保存使用
1:保存数据
[[NSUserDefaultsstandardUserDefaults] setObject:@"http://www.baidu.com"forKey:@"selectedURL"];
2:取数据
NSLog(@" 正在访问---> %@",[[NSUserDefaultsstandardUserDefaults] objectForKey:@"selectedURL"]);
3:官方说明:
Getting the Shared NSUserDefaults Instance
-
- + standardUserDefaults
- + resetStandardUserDefaults
Initializing an NSUserDefaults Object
-
- – init
- – initWithUser:
Registering Defaults
-
- – registerDefaults:
Getting Default Values
-
- – arrayForKey:
- – boolForKey:
- – dataForKey:
- – dictionaryForKey:
- – floatForKey:
- – integerForKey:
- – objectForKey:
- – stringArrayForKey:
- – stringForKey:
- – doubleForKey:
- – URLForKey:
Setting Default Values
-
- – setBool:forKey:
- – setFloat:forKey:
- – setInteger:forKey:
- – setObject:forKey:
- – setDouble:forKey:
- – setURL:forKey:
Removing Defaults
-
- – removeObjectForKey:
Maintaining Persistent Domains
-
- – synchronize
- – persistentDomainForName:
- – persistentDomainNames
- – removePersistentDomainForName:
- – setPersistentDomain:forName:
Accessing Managed Environment Keys
-
- – objectIsForcedForKey:
- – objectIsForcedForKey:inDomain:
Managing the Search List
-
- – dictionaryRepresentation
Maintaining Volatile Domains
-
- – removeVolatileDomainForName:
- – setVolatileDomain:forName:
- – volatileDomainForName:
- – volatileDomainNames
Maintaining Suites
-
- – addSuiteNamed:
- – removeSuiteNamed: