I’m currently facing in problem using Core Data. I have two entities A and B. A can have multiple B’s so there is a one-to-many relationship. The dataModel and classes are all defined correctly and are working. Now here is the problem:
When I create an entity A and some B entities and set all attributes I am able to store and load them. When the application is closed and entity A is loaded all Attributes are set correctly and it still has all the B entities. The Problem is that inside the B entities all attributes are lost and not saved. When saving the ManagedObejctContext no error occurs.
I don’t understand why fetching all B’s at the application launch they are creating works regarding the values of the attributes and fetching B’s from previous launches results in all attributes being null.
Thanks for your ideas
SOLUTION:
After building several new Entities and searching for differences I found that the properties in the B entity were somehow initialized with @synthesize and with @dynamic! That was were the problem came from
Check the following :
In the DataModel, are your 2 relationships (A have B and B belongs to A) correctly set as inverse ? (AtoB is the inverse of BtoA)
Are you sure they don’t belong to several different managedObjetcContext ?
Are you sure the modifications you do on the B items are followed by a
[self.managedObjectContext save]?