我将字典数组保存到 plist 文件中。我已经对大约 150 个实例的数组进行了测试,并且运行良好。现在我有大约 350 个并且相同的代码不起作用(它可能是由什么引起的?
不工作 = 创建一个空的 plist。
我正在使用 TouchJSON 将 JSON 解析到数组中 某些字典的某些元素具有 NULL 值(如果有帮助)
这是我用来保存数据的代码:
NSString *filePathDocArray = [DOCUMENTS stringByAppendingPathComponent:@"filters.plist"];
NSString *filePathBundleArray = [[NSBundle mainBundle] pathForResource:@"filters" ofType:@"plist"];
//if there is no current filterlist - download and parse the JSON
if (![[NSFileManager defaultManager] fileExistsAtPath:filePathDocArray])
{
[[NSFileManager defaultManager] copyItemAtPath:filePathBundleArray toPath:filePathDocArray error:nil];
NSLog(@"File saved");
}
[APIDownload downloadWithURL:@"url" delegate:self];
完成加载时调用的方法:
- (void)APIDownload:(APIDownload*)request
{
CJSONDeserializer *deserializer = [CJSONDeserializer deserializer];
self.news = [deserializer deserializeAsArray:request.downloadData error:nil];
NSString *filePathDocArray = [DOCUMENTS stringByAppendingPathComponent:@"filters.plist"];
[self.news writeToFile:filePathDocArray atomically:YES];
[news release];
if(TableViewSynthesized) {
[self.tableViewController release];
TableViewSynthesized = NO;
}
}