NSString *doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString * doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString * plistPath = [doc stringByAppendingPathComponent:@"data.plist"];
//偏好设置存数据
[[NSUserDefaults standardUserDefaults] setObject:@"save" forKey:@"save"];
[[NSUserDefaults standardUserDefaults] synchronize];
//偏好设置获取数据
[[NSUserDefaults standardUserDefaults] objectForKey:@"save"];
//删除偏好设置
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"save"];//
//NSCoding//存储数据
Contact *contact = [[Contact alloc] init];
contact.name = @"张三";
contact.age = 27;
contact.tel = @"13531232323";
[NSKeyedArchiver archiveRootObject:contact toFile:self.plistPath];
//读数据
Contact *contact = [NSKeyedUnarchiver unarchiveObjectWithFile:self.plistPath];
NSLog(@"name:%@ age:%d tel:%@ ",contact.name,contact.age,contact.tel);