views:

339

answers:

2

I have an application that downloads/parses a big XML file and store the information using core data (approx. 4000 objects (entities)). The XML is loaded/parsed in a different thread, which has its own NSManagedObjectContext.

When trying to save the entities to the persistent store, I sometimes get the following error (about 20%)

2010-03-03 23:41:42.802 xxx[7487:4203] Exception in XML saving
2010-03-03 23:41:42.802 xxx[7487:4203] Description: * -_referenceData64 only defined for abstract class. Define -[NSTemporaryObjectID_default _referenceData64]!
2010-03-03 23:41:42.803 xxx[7487:4203] Name: NSInvalidArgumentException
2010-03-03 23:41:42.804 xxx[7487:4203] UserInfo: (null)
2010-03-03 23:41:42.805 xxx[7487:4203] Reason: *
-_referenceData64 only defined for abstract class. Define -[NSTemporaryObjectID_default _referenceData64]!

I have a simple integer to keep track of the entities the application creates compared to the insertedObjects property in the NSManagedObjectContext before saving, and when I get the error, these numbers do not match, insertedObjects in the NSManagedObjectContext is missing about 10 entities.

I do not know how I should continue to investigate this problem, anyone has any idea how to fix this?

Thanks /oscar

A: 

I had the same problem with core data and multithreading operations. Read this article for understanding of the problem.

In the working thread I began to use the functions lock, unlock for NSManagedObjectContext and crash not repeat any more.

Victor
+1  A: 

Do you use custom NSManagedObject subclasses for your entities? This problem can occur if you do incorrect initializations etc. in initWithEntity:insertIntoManagedObjectContext:

Diederik Hoogenboom