在我的应用程序中,我在后台线程中从服务器下载 XML 数据,然后解析和更新数据库表
后台线程将在应用程序启动期间创建并继续运行。
但问题是在 NSXMLParser 对象发布期间,我得到 EXC_BAD_ACCESS (SIGSEGV) 这是 XML Parser 代码:
- (void)parseXMLWithData:(NSMutableData *)pObjXMLBufferPtr
{
@try
{
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
NSMutableData *lTempData = [pObjXMLBufferPtr copy];
NSXMLParser *lObjXMLParserPtr = [[NSXMLParser alloc] initWithData:lTempData];
[lTempData release];
[pObjXMLParserPtr setShouldResolveExternalEntities: YES];
[pObjXMLParserPtr setDelegate: m_cObjSAXHandler];
//m_cObjSAXHandler is my custom class. here is declaration SAXHandler :
NSObject<NSXMLParserDelegate>
[pObjXMLParserPtr parse];
[lObjXMLParserPtr setDelegate:nil];
[lObjXMLParserPtr release];
lObjXMLParserPtr = (NSXMLParser *)nil;
}
@catch (NSException *ex)
{
NSLog(@"parseXMLWithData Exception!!!");
}
}
Here is the crash log:
0 libicucore.A.dylib 0x34c00578 ucnv_close + 28
1 libxml2.2.dylib 0x342a81ba xmlCharEncCloseFunc + 30
2 libxml2.2.dylib 0x342c62d0 xmlFreeParserInputBuffer + 28
3 libxml2.2.dylib 0x342aacbc xmlFreeInputStream + 108
4 libxml2.2.dylib 0x342aace4 xmlFreeParserCtxt + 12
5 Foundation 0x37d14b22 -[NSXMLParser dealloc] + 158
请帮我解决这个问题。