NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"plistdemo" ofType:@"plist"];
NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
NSLog(@"%@", data);

//添加一项内容
[data setObject:@"add some content" forKey:@"c_key"];

//获取应用程序沙盒的Documents目录
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *plistPath1 = [paths objectAtIndex:0];

//得到完整的文件名
NSString *filename=[plistPath1 stringByAppendingPathComponent:@"test.plist"];
//输入写入
[data writeToFile:filename atomically:YES];

//那怎么证明我的数据写入了呢?读出来看看
NSMutableDictionary *data1 = [[NSMutableDictionary alloc] initWithContentsOfFile:filename];
NSLog(@"%@", data1);

相关文章:

  • 2021-10-05
  • 2021-07-06
  • 2021-06-10
  • 2022-02-14
  • 2021-09-13
  • 2021-10-22
  • 2022-12-23
猜你喜欢
  • 2022-01-15
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2021-08-01
相关资源
相似解决方案