将字典写入属性列表文件中

我与影子孤独终老i 提交于 2020-01-03 05:58:08
 1 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
 2     [dict setObject:@"mj" forKey:@"name"];
 3     [dict setObject:[NSNumber numberWithInt:10] forKey:@"age"];
 4     
 5     // 获取应用沙盒的根路径
 6     NSString *home = NSHomeDirectory();
 7     NSString *documents = [home stringByAppendingPathComponent:@"Documents"];
 8     // 属性列表的默认拓展名是plist
 9     NSString *path = [documents stringByAppendingPathComponent:@"dict.plist"];
10     
11     [dict writeToFile:path atomically:YES];

 

 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!