一、plist文件
项目中新建的plist文件读取
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"address" ofType:@"plist"];
NSDictionary *data = [NSDictionary dictionaryWithContentsOfFile:plistPath];
代码添加的plist文件
NSString *componentPath = @"demo.plist";
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [pathArray.firstObject stringByAppendingPathComponent:componentPath];
//增
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data setObject:@"对象1" forKey:@"关键字1"];
[data setValue:@"对象2" forKey:@"关键字2"];
[data setValue:@"对象3" forKeyPath:@"关键字3"];
[data writeToFile:path atomically:YES];
//删
data = [NSMutableDictionary dictionaryWithContentsOfFile:path];
[data removeObjectForKey:@"关键字1"];
[data writeToFile:path atomically:YES];
//改
//查
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithContentsOfFile:path];