从xx.json文件中读取JSON数据,写入到xx.plist文件中,实现代码如下:
NSString *path = @"/Users/apple/Desktop/testJtoP/testJtoP/1_category.json";
NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil];
BOOL state = [array writeToFile:@"/Users/apple/Desktop/1_category.plist" atomically:YES];
if(state){
NSLog(@"成功");
}else{
NSLog(@"失败");
}
ps:需在模拟器上运行
writeToFile写入不成功的原因 :
If an array or dictionary contains objects that are not property-list objects, then you cannot save and restore the hierarchy of data using the various property-list methods and functions.