My document-based Cocoa application uses a NSOutlineView/NSTreeController combo, bound to the document's Core Data store. My NSTreeController has the fetch predicate isRoot == YES
. isRoot
is a transient boolean attribute with a default value of NO
. My root model's awakeFromInsert
calls:
[self setIsRoot:[NSNumber numberWithBool:YES]];
I'm able to add objects to the hierarchy just fine, but when I try to load a document I just saved, I get an exception:
[<NSDictionaryMapNode 0x1001a8190> valueForUndefinedKey:]: this class is not key value coding-compliant for the key isRoot.
I can work around this exception and successfully load a newly-saved document if I change the isRoot
attribute to non-transient in the xcdatamodel, but based on my understanding of the transient flag it should not cause a problem, and this really isn't the kind of data that should be persisted.
I have also tried implementing -isRoot
in the NSManagedObject subclasses to return the appropriate fixed value, as well as making the same setIsRoot:
call within awakeFromFetch
, both to no avail.
Is there some other subtlety I'm missing? I can't imagine that fetch predicates don't support transient attributes. I don't know much about the inner workings of Core Data but it seems interesting that it's trying to look up isRoot
on the store-specific class and not my NSManagedObject subclass.