Re: Binding to displayName
Re: Binding to displayName
- Subject: Re: Binding to displayName
- From: Ken Thomases <email@hidden>
- Date: Sun, 5 Oct 2008 10:26:16 -0500
On Oct 5, 2008, at 3:55 AM, Gerriet M. Denkmann wrote:
When the Inspector gets loaded I get:
... KVO autonotifying only supports -set<Key>: methods that return
void. Autonotifying will not be done for invocations of -
[MyDocument _setDisplayName:].
[...]
Why does displayName complain? What am I doing wrong?
It seems pretty clear from the above message.
When you set up a binding or otherwise add a KVO observer, the KVO
machinery attempts to hook into the setter for the named property.
There are a number of method names it checks to find the relevant
setter. In your case, it's finding _setDisplayName: (presumably, you
don't provide setDisplayName: without the leading underscore). The
problem is that KVO expects setters to have a return type of void. It
checks that for a couple of reasons: the pragmatic reason is that it
doesn't know how to implement an override for a method which returns a
value. Another reason is that it's trying to be careful to only hook
into methods which actually are what it expects -- a normal-seeming
setter. A setter which returns a value doesn't seem normal, so KVO
backs off and assume the method isn't a setter even though its name
suggested it might be.
In other words, you should redesign your -[MyDocument
_setDisplayName:] method so that it returns void.
Cheers,
Ken
_______________________________________________
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