标签:
用于存储串行化对象,xml格式,存储到plist文件中。
存储用户设置。
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSString *filePath = [documentPath stringByAppendingPathComponent:@"student.plist"];
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; NSDictionary *stu1= @{@"idNum":@"1",@"name": @"jereh"}; [dict setValue:stu1 forKey:@"stu1"]; // 新数据写入plist文件 [dict writeToFile:filePath atomically:YES];
NSMutableDictionary *dicNow = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; int idNum = [[dicNow objectForKey:@"idNum"] intValue]; NSString *name = [dicNow objectForKey:@"name"];
标签:
原文地址:http://www.cnblogs.com/SimonGao/p/5031679.html