0
私は、大きなxmlを解析し、それを一時的なコアデータテーブルに格納する作業を進めています。次のように私のパーサdidEndElement方法はなりますNSXMLParserのオブジェクトに以前の値が保持されないのはなぜですか?
-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"reference_number"]) {
[[self pdfDocument] setEducationDocumentReference:currentTextString];
}
if ([elementName isEqualToString:@"name"]) {
[[self pdfDocument] setEducationDocumentName:currentTextString];
}
if ([elementName isEqualToString:@"type"]) {
[[self pdfDocument] setEducationDocumentType:currentTextString];
}
if ([elementName isEqualToString:@"date"]) {
[[self pdfDocument] setEducationDocumentDate:[dateFormatter dateFromString:currentTextString]];
}
if ([elementName isEqualToString:@"url"]) {
[[self pdfDocument] setEducationDocumentURL:currentTextString];
//If I uncomment the following, the app will try finding the previous set
//values without any luck and crash.
//if (![pdfDocument documentExistsInTemporaryTable]) {
// [pdfDocument saveDocumentToTemporaryTable];
//}
}
}
それがあるべきとしてそれは明らかにすべての値を分離し、それは一時テーブルにオブジェクトを保存する前にpdfDocumentオブジェクトにそれを格納する必要がありますが、私はいずれかにアクセスしようとすると、以前に設定したpdfDocumentの値私は、以前のpdfDocument変数の値が見つからないため、私が見ることのできるEXEC_BAD_ACCESSを取得します。
私はルーキーミスをしていると確信していますが、誰かが正しい方向に私を啓発することができますか?
あなたの問題はコードの他の部分にあります。あなたのプログラムがクラッシュした場所で、 'documentExistsInTemporaryTable'のコードを投稿する必要があります!あなたのプログラムをクラッシュさせたコードを見ずに、どうすればあなたのバグを見つけることができましたか?** – Yuji