iphone - Core Data executeFetchRequest throws NSGenericException (Collection was mutated while being enumerated) -
I am developing an iPhone app with core data All user data should be synchronized with our servers for this purpose For I created a sub-section of NSOption witch load from our web service and created related managed objects. To maintain the relationship between them, each object is transmitted with RemoteID (which is the primary key of the relational server DB).
Assume that there are two managed objects: Department & lt; - >> Employee. Synchronization works as follows:
-
Load all departments from server for each department: Create a department object and set its remote ID.
-
Load all employees from the server For each employee: Create an employee object, get the related department by Remotid and provide it to the employee.
The following exception is made by bringing a department:
Every time an exception is not thrown, the problem is to move the code to the main thread. I do not know what is wrong. I have created a new NSManagedObjectContaxt in the synchronization thread and passed all object objects by its managed NSMANG object.
Any thoughts?
I had the same problem ... it was fixed because I managed object contexts Which was built on the main thread on the background thread. Its solution was to create a separate managed object contact on the background thread, and the regular Stustor Coordinator was used ... after that it worked fine!
Comments
Post a Comment