UserDefault的使用,保存小数据到本地-iOS
//保持到本地数据
NSArray *array=@[@"234",@"sdfe"];
NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
[userDefault setInteger:123 forKey:@"number"];
[userDefault setObject:array forKey:@"array"];
[userDefault synchronize];
//获取保持到数据
NSUserDefaults *userdefault2=[NSUserDefaults standardUserDefaults];
NSInteger number2=[userdefault2 integerForKey:@"number"];
NSArray *array2=[userdefault2 objectForKey:@"array"];
NSLog(@"number=%d,array=%@",number2,array2);
posted on 2014-08-16 18:58 clarenceV1 阅读(814) 评论(0) 编辑 收藏 举报