辞書の配列を 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;
}
}