Reputation: 455
Im having some trouble figuring out why Core Data isn't firing a fault when i access an attribute in an entity relationship?
I have a feeling the reason might be due to the way I am subclassing my NSManagedObjects which is like so:
NSManagedObject
|
MYManagedObject (NSNumber *id)
|
MYSimpleManagedObject (NSString *name)
|
Employee
\
Manager
and
NSManagedObject
|
MYManagedObject (NSNumber *id)
|
MYSimpleManagedObject (NSString *name)
|
Manager
\
Employee
In the scenario above Employee and Manager are both subclasses of a couple of other Classes which are not in themselves Entities in my data model but rather regular classes i have used to encapsulate code and properties such as id and name which are common to a number of Entities. This model has worked really well for me however my problem is that the following statement does not fire a fault manager.employee.name
however if instead i use [manager valueForKeyPath:@"employee.name"]
the fault is fired and i get the value i need.
Do i need to override any accessor methods or something in order for the value to fire a fault?
Upvotes: 0
Views: 719
Reputation: 80271
In the model editor you can specify certain entities to have parent entities. I would recommend modeling both parent entities in Core Data and specifying the parent-child relationship.
In my experience, your accessors should then work as expected.
Upvotes: 0