因此,在我的应用程序中,我从 XML Web 服务中检索数据。它非常巨大。多达 30-40000 条记录。在模拟器上它工作正常。但是在设备上它正在崩溃。我使用 NSXMLParser。开始元素,结束元素。所以它在某个时候崩溃了。但是,我在后台线程中执行此操作,以免破坏我的主线程。如果它超过 10 秒,也可以阻止 iOS 停止踢出我的应用程序。所以任何想法如何纠正它。我一直在这个时间,但没有解决方案。任何帮助,将不胜感激。谢谢。
0 CoreFoundation 0x3baa839c __CFBasicHashAddValue + 1452
1 CoreFoundation 0x3b9d2194 CFBasicHashAddValue + 3048
2 CoreFoundation 0x3b9d5ebc CFSetAddValue + 112
3 CoreData 0x3709b5b0 -[NSManagedObjectContext(_NSInternalAdditions) _insertObjectWithGlobalID:globalID:] + 172
4 CoreData 0x370939bc -[NSManagedObjectContext insertObject:] + 136
5 CoreData 0x370836d2 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 646
6 CoreData 0x3706fd74 +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 176
7 XYZ Orders 0x00146c68 -[ITMParser parser:didEndElement:namespaceURI:qualifiedName:] (ITMParser.m:393)
8 Foundation 0x36898a82 _endElementNs + 298
9 libxml2.2.dylib 0x3ad8de5a xmlParseEndTag2 + 614
10 libxml2.2.dylib 0x3ad8f546 xmlParseTryOrFinish + 1658
11 libxml2.2.dylib 0x3ad8ece8 xmlParseChunk + 208
12 Foundation 0x3689755e -[NSXMLParser parse] + 482
13 XYZ Orders 0x0017a4c4 -[ITMLoginVC getAllCustomerValues] (ITMLoginVC.m:822)
14 XYZ Orders 0x00176a6c __25-[ITMLoginVC viewDidLoad]_block_invoke_0 (ITMLoginVC.m:218)
15 libdispatch.dylib 0x39d8011c _dispatch_call_block_and_release + 8
16 libdispatch.dylib 0x39d8495c _dispatch_root_queue_drain + 248
17 libdispatch.dylib 0x39d84abc _dispatch_worker_thread2 + 80
18 libsystem_c.dylib 0x36ae9a0e _pthread_wqthread + 358
19 libsystem_c.dylib 0x36ae98a0 start_wqthread + 4
- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if([elementName isEqualToString:@"NAllAddresses"])
{
NSString *temp=@"";
self.managedObjectContext = appDelegate.managedObjectContext;
//The below line happens to be the line number 393.
ITMAllCustomerAddresses *allCustAddress =(ITMAllCustomerAddresses *)[NSEntityDescription
insertNewObjectForEntityForName:@"ITMAllCustomerAddresses"
inManagedObjectContext:self.managedObjectContext];
allCustAddress.allAddID = [self numberValue:[self.mutableDictionary objectForKey:@"AllAddID"]];
allCustAddress.allCustID = [self numberValue:[self.mutableDictionary objectForKey:@"AllCustID"]];
temp =[self.mutableDictionary objectForKey:@"AllAddressLine"];
allCustAddress.allAddressLine = [self noSpaceString:temp];
temp = [self.mutableDictionary objectForKey:@"AllAddressCity"];
allCustAddress.allAddressCity = [self noSpaceString:temp];
temp = [self.mutableDictionary objectForKey:@"AllAddressState"];
allCustAddress.allAddressState = [self noSpaceString:temp];
temp = [self.mutableDictionary objectForKey:@"AllAddressZip"];
allCustAddress.allAddressZip = [self noSpaceString:temp];
[self.allCustomerAddressesArray addObject:allCustAddress];
[self.mutableDictionary removeAllObjects];
}
else
{
if([elementName isEqualToString:@"AllAddID"]||[elementName isEqualToString:@"AllCustID"] ||[elementName isEqualToString:@"AllAddressLine"]||[elementName isEqualToString:@"AllAddressCity"]||[elementName isEqualToString:@"AllAddressState"]||[elementName isEqualToString:@"AllAddressZip"])
{
[self.mutableDictionary setObject:currentElementValue forKey:elementName];
currentElementValue = nil;
}
}