Op 12 nov 2010, om 19:16 heeft Quincey Morris het volgende geschreven:
As as been said several times in this thread, you *shouldn't* override 'valueForKey:', but instead override 'valueForUndefinedKey:' like this:

Is this kind of override ok?:
valueForKey: {
        [properties valueForKey:key];
}

Otherwise the valueForKey is called on my wrapper, instead of the dictionary that contains the real keys. I don't see how else the KVC logic should find out about that instance variable.


@implementation PropertiesController
- (id) valueForUndefinedKey: (NSString*) key {
        id retVal=[properties objectForKey:key]; // note: NOT 'valueForKey:'
        if (!retVal) {
                //fetch value from network
                //We do not wait for the value
        }
        return retVal;
}
@end

If you want to know how control reaches this method, read the documentation:

http://developer.apple.com/library/mac/#documentation/Cocoa/ Conceptual/KeyValueCoding/Concepts/SearchImplementation.html%23// apple_ref/doc/uid/20000955-CJBBBFFA

Unfortunatly, this does not seem to hold for a NSDictionary. It always returns something instead of calling valueForUndefinedKey:

Regards,

Remco Poelstra

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to