ios开发 json数据文件的存取
生活随笔
收集整理的這篇文章主要介紹了
ios开发 json数据文件的存取
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
將Json存進本地文件夾 NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); ????NSString *path=[paths objectAtIndex:0]; ????NSString *Json_path=[path stringByAppendingPathComponent:@"JsonFile.json"]; ????//==寫入文件 ????NSLog(@"%@",[JsonData writeToFile:Json_path atomically:YES] ? @"Succeed":@"Failed"); ----------------------- 讀取Json //==Json文件路徑 ????NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); ????NSString *path=[paths objectAtIndex:0]; ????NSString *Json_path=[path stringByAppendingPathComponent:@"JsonFile.json"]; ????//==Json數據 ????NSData *data=[NSData dataWithContentsOfFile:Json_path]; ????//==JsonObject ????id JsonObject=[NSJSONSerialization JSONObjectWithData:data ???????????????????????????????????????????????????options:NSJSONReadingAllowFragments ?????????????????????????????????????????????????????error:&error] ??//nslog (@"%@",jsonobject);打印json字典
轉載于:https://www.cnblogs.com/yjg2014/p/4057991.html
總結
以上是生活随笔為你收集整理的ios开发 json数据文件的存取的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 是否是工作日和节假日判定
- 下一篇: 极大似然估计(Maximum Likel