本地造假数据模拟服务器给的json

2019-04-14 12:33发布

读取.json文件代码部分

NSString * json = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"json"]; NSData *data=[NSData dataWithContentsOfFile:json]; NSError *error; NSDictionary * dict =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];