Re: setValue:forKey: and invocation forwarding
Re: setValue:forKey: and invocation forwarding
- Subject: Re: setValue:forKey: and invocation forwarding
- From: Mike Abdullah <email@hidden>
- Date: Tue, 13 Jul 2010 14:51:55 +0100
Sounds to me you subclassed the wrong class. KVC is provided by NSObject. If you subclass NSProxy, the -setValue:forKey: message is not implemented, so will get forwarded on like others.
On 13 Jul 2010, at 13:53, Graham Cox wrote:
> It appears that calling -setValue:forKey: on an object bypasses or ignores any invocation forwarding it has set up, unless I'm missing some obvious error.
>
> I have an object that acts as a wrapper for another object, and so that the wrapper can, under some circumstances, act as the thing it is wrapping, it implements invocation forwarding using the 'classic' approach of overriding -respondsToSelector:, -methodSignatureForSelector: and -forwardInvocation: but when I call -setValue:forKey: on the wrapper (where key is implemented by the thing wrapped), it throws the 'not key-value coding compliant for key' exception. The stack trace appears to show that this failure occurs before it has even attempted to follow the forwarded path. However if I simply call the wrapped property setter directly, the forwarding works. As this needs to work on 10.5, I can't use the 10.6 solution of -forwardingTargetForSelector: (not that I've tested it to see if it exhibits the same issue or not).
>
> Is this the expected behaviour?
>
> --Graham
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden