當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
IOS开发之JSON文件的读写
生活随笔
收集整理的這篇文章主要介紹了
IOS开发之JSON文件的读写
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
IOS開發之JSON文件的讀寫
// // ViewController.m // 20-JSON的讀寫 // // Created by 魯軍 on 2021/2/13. //#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.// [self saveJSOn];[self readJson];}-(void)readJson{NSData *data=[NSData dataWithContentsOfFile:@"/Users/lujun/Desktop/111.json"];id json =[NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];NSLog(@"%@",json);}-(void)saveJSOn{NSDictionary *dict =@{@"name":@"dajun",@"age":@(19)};NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:NULL];[data writeToFile:@"/Users/lujun/Desktop/111.json" atomically:YES];}@end總結
以上是生活随笔為你收集整理的IOS开发之JSON文件的读写的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux触发连锁反应,惠及全球
- 下一篇: 谈判学:三招了解对方底线