// 向plist文件中存储数据
NSString *home = NSHomeDirectory();
NSString *docPath = [home stringByAppendingPathComponent:@"Document"];
NSArray *data = @[@"jack", @10, @"ffdsf"];
NSString *filePath = [docPath stringByAppendPathComponent:@"data.plist"];
[data writeToFile:filePath atomically:YES];
// 偏好设置存储数据
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"mj" forKey:@"account"];
[defaults setInteger:10 forKey:@"age"];
[defaults setBool:YES forKey:@"auto_login"];
[defaults synchronize];
NSString *account = [defaults objectForKey:@"account"];
时间: 2024-11-09 00:03:47