iOS app crashing while parsing XML in TBXML

Discussion in 'iOS Programming' started by RookieAppler, Jan 29, 2013.

  1. RookieAppler, Jan 29, 2013
    Last edited by a moderator: Jan 29, 2013

    macrumors member

    Joined:
    Mar 15, 2012
    #1
    I am creating a universal app. The app works fine in simulator (iPhone and iPad). But on the iPhone device it crashes. It works fine on iPad device.I am parsing xml from a ASMX web service. I am using TBXML. I have 8 method calls in my service. So each one returns an XML of class like below "ITMAllCustomerDetails", "ITMAllPhoneNumbers",...etc. So the app crashes sporadically at insertNewObject for either of them..(any of the 8)
    Here is my crash log:
    Code:
    Thread 3 name:  Dispatch queue: com.apple.root.default-priority
    Thread 3 Crashed:
    0   CoreFoundation                	0x3b8b1408 __CFBasicHashAddValue + 1560
    1   CoreFoundation                	0x3b7db194 CFBasicHashAddValue + 3048
    2   CoreFoundation                	0x3b7deebc CFSetAddValue + 112
    3   CoreData                      	0x36ea45b0 -[NSManagedObjectContext(_NSInternalAdditions) _insertObjectWithGlobalID:globalID:] + 172
    4   CoreData                      	0x36e9c9bc -[NSManagedObjectContext insertObject:] + 136
    5   CoreData                      	0x36e8c6d2 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 646
    6   CoreData                      	0x36e78d74 +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 176
    7   XYZ Orders                    	0x001063c4 -[ITMLoginVC traverseElement:] (ITMLoginVC.m:1587)
    8   XYZ Orders                    	0x00105f16 -[ITMLoginVC traverseElement:] (ITMLoginVC.m:1511)
    9   XYZ Orders                    	0x00103a90 -[ITMLoginVC getAllCustomerValues] (ITMLoginVC.m:951)
    10  libdispatch.dylib             	0x39b8911c _dispatch_call_block_and_release + 8
    11  libdispatch.dylib             	0x39b8d95c _dispatch_root_queue_drain + 248
    12  libdispatch.dylib             	0x39b8dabc _dispatch_worker_thread2 + 80
    13  libsystem_c.dylib             	0x368f2a0e _pthread_wqthread + 358
    14  libsystem_c.dylib             	0x368f28a0 start_wqthread + 4
    
    The line 951 is
    Code:
    	strPath = @"";//some valid URL path
    	ttbXML = [TBXML tbxmlWithURL:[NSURL URLWithString:strPath]];
    	if(ttbXML.rootXMLElement)
    	{
    		[self traverseElement:ttbXML.rootXMLElement]; //line 951
    	}
    	else
    	{
    		NSLog(@"the else at 944");
    	}
    
    Line 1511 is
    Code:
     if (element->firstChild)
                [self traverseElement:element->firstChild]; // line 1511
    
    Line 1587 is:
    Code:
    - (void) traverseElement:(TBXMLElement *)element {
    	if (!self.managedObjectContext)
        {
            self.managedObjectContext  = self.appDelegate.managedObjectContext;
    	}
    	
        do {
            if (element->firstChild)
                [self traverseElement:element->firstChild];
    ........
    else if ([[TBXML elementName:element] isEqualToString:@"NCustomerDetails"])
    		{
    			NSString *temp=@"";
    			ITMAllCustomerDetails *allCustDetails =(ITMAllCustomerDetails *)[NSEntityDescription
    																	insertNewObjectForEntityForName:@"ITMAllCustomerDetails"
    																			 inManagedObjectContext:self.managedObjectContext]; //line 1587
    
    I am thinking is there some problem with my managedobjectcontext. I am creating like you see above. If this is not clear and you need more information, please ask. Thanks.
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Are you accessing the same moc from multiple threads? I think that's not legal.

    What does crash mean? SIGALRT? BAD_ACCESS? WHAT?
     

Share This Page