//存
- (IBAction)save:(id)sender {
//获取存储对象 以字典形式存储 无需关心文件名和路径 读取只需通过key
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"张三" forKey:@"name"];
}
//取
- (IBAction)read:(id)sender {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *name = [userDefaults objectForKey:@"name"];
NSLog(@"%@", name);
}
偏好存储
最新推荐文章于 2020-03-25 16:33:13 发布