Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSManagedObject can't get attributes from NSAtomicStoreCacheNode

I have one-to-one relationship between entity A and entity B (one sided), for example named bRel. I have subclasses of NSAtomicStore (MyStore) and NSAtomicStoreCacheNode (MyCacheNode). In the load: method of MyStore I create instances of MyCacheNode for entities A and B (aNode and bNode) and assign corresponding propertyCache dictionary for each one. The propertyCache for aNode contains bNode for key @"bRel".

The aManagedObject is created normally and has all the properties valid. But when aManagedObject accesses the bManagedObject through the aManagedObject.bRel.someAttribute, the bManagedObject remains fault. bManagedObject doesn't receive awakeFromInsert or awakeFromFetch. The bNode and bManagedObject share the same instance of managedObjectID. The bNode is alive when bManagedObject accesses someAttribute. When aManagedObject accesses its attributes, it goes through the valueForKey: of MyCacheNode. When bManagedObject does, we don't get there.

bManagedObject just never fires at all.

Can anyone suppose what should I check in this situation?

like image 514
Over Ukraine Avatar asked Oct 31 '12 21:10

Over Ukraine


2 Answers

yes. the problem may be that you have a Forward Declaration of aRel on your managed object. Try importing it on the aManagedObject.h file. that way, you should be able to access it's attributes.

Let me know how it goes :)

like image 112
Wiz Avatar answered Oct 24 '22 03:10

Wiz


From current perspective I think I've just didn't call willAccessValueForKey:/didAccessValueForKey: for synthesised properties, and that was irrelevant to customising store. B was the synthesised property of A, AFAIR.

like image 33
Over Ukraine Avatar answered Oct 24 '22 05:10

Over Ukraine