//采用NSUserDefaults实现
//创建NSUserDefaults
NSUserDefaults *firstrecognition=[NSUserDefaults standardUserDefaults];
if ([firstrecognition boolForKey: @"firstrecognition"]!=YES) {
[firstrecognition setBool:YES forKey:@"firstrecognition"];
[firstrecognition boolForKey: @"firstrecognition"];
NSLog(@"firstrecognition : no");
}
//添加text内的数据:
// [firstrecognition setObject:first.text forKey:@"firstrecognition"];
//也可以添加基本数据类型int, float, bool等,有相应得方法
[firstrecognition setBool:YES forKey:@"firstrecognition"];
// 从user defaults中获取数据:
// [firstrecognition objectForKey:@"firstrecognition"];
[firstrecognition boolForKey: @"firstrecognition"];
NSLog(@"firstrecognition : yes");
//下面是运行结果,图1为首次运行结果,图2为第二次运行结果