0
我的JSON文件是这样的:的iOS:将数据写入到JSON文件编程
{
"images": [
"straight up kick.png",
"women kick.png",
"Taekwondo Kanji vertical.png",
"face kick3.png",
"flexibility.png",
"Punch.png",
"hook kick.png",
"front kick 2.png"
]
}
我读上面的JSON编程象下面这样:
NSString *path = [[NSBundle mainBundle] pathForResource:@"generated" ofType:@"json"];
NSData *data = [NSData dataWithContentsOfFile:path];
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSMutableArray * jsonimages = [dict objectForKey:@"images"];
NSLog(@"images %@", jsonimages);
我想添加更多的项目到数组命名作为通过以编程方式写入json文件的jsonimages。 JSON文件名是generated.json。
任何帮助,将不胜感激。
你有什么试过的?你的问题是在'dict'中添加对象(注意它不可变),'jsonimages'还是将它保存下来?因为你不能写入'[NSBundle mainBundle]'。 – Larme