标签:nsuserdefault 数据存储 键值对 偏向设置 数据持久化
实例:NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; NSString *countName = self.inputCount.text; [defaults setBool:_rememberPassword.on forKey:@"rememberPwd"]; [defaults synchronize];
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults]; self.inputCount.text = [defaults objectForKey:@"countName"]; [defaults synchronize];
0、+standardUserDefaults返回的是一个共享的defaults独享
+ (void)resetStandardUserDefaultsA subsequent invocation of standardUserDefaults creates a new shared user defaults object with the standard search list.
- (instancetype)init返回值是:这个初始化NSUserDefaults对象的参数和动态注册已经建立
3、返回一个NSUserDefaults对象初始化通过指定的app组。
- (instancetype)initWithSuiteName:(NSString *)suitename参数: suitename app的名字
- (void)addSuiteNamed:(NSString *)suiteName; - (void)removeSuiteNamed:(NSString *)suiteName;
- (void)registerDefaults:(NSDictionary *)dictionary参数:dictonary就是设置的key和值想用来注册的。
- (NSArray *)arrayForKey:(NSString *)defaultName; - (BOOL)boolForKey:(NSString *)defaultName; - (NSData *)dataForKey:(NSString *)defaultName; - (NSDictionary *)dictionaryForKey:(NSString *)defaultName; - (float)floatForKey:(NSString *)defaultName; - (NSInteger)integerForKey:(NSString *)defaultName; - (id)objectForKey:(NSString *)defaultName; - (NSArray *)stringArrayForKey:(NSString *)defaultName; - (NSString *)stringForKey:(NSString *)defaultName; - (double)doubleForKey:(NSString *)defaultName; - (NSURL *)URLForKey:(NSString *)defaultName NS_AVAILABLE(10_6, 4_0);
- (void)setBool:(BOOL)value forKey:(NSString *)defaultName; - (void)setFloat:(float)value forKey:(NSString *)defaultName; - (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName; - (void)setObject:(id)value forKey:(NSString *)defaultName; - (void)setDouble:(double)value forKey:(NSString *)defaultName; - (void)setURL:(NSURL *)url forKey:(NSString *)defaultName NS_AVAILABLE(10_6, 4_0);
- (void)removeObjectForKey:(NSString *)defaultName;
- (BOOL)synchronize;8.2返回指定的数组在指定的持久域内。
- (NSArray *)persistentDomainNames NS_DEPRECATED(10_0, 10_9, 2_0, 7_0);
- (NSDictionary *)persistentDomainForName:(NSString *)domainName;
- (void)removeVolatileDomainForName:(NSString *)domainName;
- (void)setPersistentDomain:(NSDictionary *)domain forName:(NSString *)domainName;
- (BOOL)objectIsForcedForKey:(NSString *)key; - (BOOL)objectIsForcedForKey:(NSString *)key inDomain:(NSString *)domain;
- (NSDictionary *)dictionaryRepresentation;
- (void)removePersistentDomainForName:(NSString *)domainName; //删除 - (NSDictionary *)volatileDomainForName:(NSString *)domainName;//获取 - (void)setVolatileDomain:(NSDictionary *)domain forName:(NSString *)domainName;//设置 @property (readonly, copy) NSArray *volatileDomainNames;//属性
NSUserDefaultsDidChangeNotification
extern NSString *NSGlobalDomain; //所有的应用都是可见的。 extern NSString *NSArgumentDomain; //这个域包括默认的解析从应用的参数,这些是一个或者多个对从默认的值中包括应用的命令行(命令行也是可见的) extern NSString *NSRegistrationDomain;//短暂的 还有其他的表示时间等等的一些常量: FOUNDATION_EXPORT NSString * const NSWeekDayNameArray NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSShortWeekDayNameArray NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSMonthNameArray NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSShortMonthNameArray NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSTimeFormatString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSDateFormatString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSTimeDateFormatString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSShortTimeDateFormatString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSCurrencySymbol NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSDecimalSeparator NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSThousandsSeparator NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSDecimalDigits NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSAMPMDesignation NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSHourNameDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSYearMonthWeekDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSEarlierTimeDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSLaterTimeDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSThisDayDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSNextDayDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSNextNextDayDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSPriorDayDesignations NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSDateTimeOrdering NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSInternationalCurrencyString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSShortDateFormatString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSPositiveCurrencyFormatString NS_DEPRECATED(10_0, 10_5, NA, NA); FOUNDATION_EXPORT NSString * const NSNegativeCurrencyFormatString NS_DEPRECATED(10_0, 10_5, NA, NA);
标签:nsuserdefault 数据存储 键值对 偏向设置 数据持久化
原文地址:http://blog.csdn.net/u012496940/article/details/47776881