|
Hi there,
I must be missing something darn obvious; looks like I've missed EOF 101 somehow :/
My EO class, which extends ERXGenericRecord, does not implement modelled property setters. Thus, I assumed takeValueForKey would always fall through handleTakeValueForUnboundKey. Seems not.
I've overridden the methods like this:
===
class OCSEnterpriseObject extends ERXGenericRecord {
static boolean canAccessFieldsDirectly { NO }
void takeValueForKey(value,String key) {
println "???takeValueForKey $key"
//super.takeValueForKey(value, key) // precisely same behaviour as with the thing below, no difference
NSKeyValueCoding.DefaultImplementation.takeValueForKey(this,value,key)
}
void handleTakeValueForUnboundKey(value,String key) {
println "???handleTakeValueForUnboundKey $key"
// ... some stuff to simulate setter (eventually using takeStoredValueForKey), not relevant, for it is never called
}
...
}
===
It does NOT work as (I've naïvely) presumed.
When eo.takeValueForKey(o,key) is called, I can always see “???takeValueForKey” (naturally), but I *never ever* see “???handleTakeValueForUnboundKey“ for any key amongst modelled attributes. Nothing other (known to me) gets called — not even takeStoredValueForKey, which I've also overridden to log —, but the value is set all right in the EO.
Only if foo is a random (non-existing, non-modelled) string, I can see “???handleTakeValueForUnboundKey“.
Looks like there's some trick in NSKeyValueCoding.DefaultImplementation.takeValueForKey which recognises modelled attributes in EOGenericRecord and fill their values directly, without falling to handleTakeValueForUnboundKey?!? Weird.
Or I must be doing something very far wrong.
Is this documented somewhere? Far as I can say, neither ERXGenericRecord nor EOGenericRecord nor NSKeyValueCoding.DefaultImplementation mentions anything special; NSKeyValueCoding.DefaultImplementation.takeValueForKey should simply check for the accessor (either with or without the _ prefix) and if there is none (which there indeed is not), fall to handleTakeValueForUnboundKey. What am I missing here?
Thanks,
OC
|
|