On 05/03/2008, at 2:10 PM, Kyle Sluder wrote:

On Tue, Mar 4, 2008 at 11:49 AM, Jim Turner <[EMAIL PROTECTED]> wrote:
In attempting to use a custom setter for a object, I'm getting the
following message in the console the first time that object is
instantiated:

KVO autonotifying only supports -set<Key>: methods that return void.
Autonotifying will not be done for invocations of -[MyObject
setValue:]

[snip]

-(void) setValueForBindings:(id)_value
{
       [self willChangeValueForKey:@"value"];
       {
BOOL didSetOK = [self setStringValue:(NSString *)_value];
               // Do something with didSetOK
       }
       [self didChangeValueForKey:@"value"];
}

Please re-read the second sentence of that error again.  You are
manually invoking -willChangeValueForKey: and -didChangeValueForKey:
and KVO is complaining "I've already done that!".  Either stop doing
that, or implement -automaticallyNotifiesObserversForKey: to return NO
for the "bindings" key.

Implementing -automaticallyNotifiesObserversForKey: will solve the problem but just removing the calls to -willChangeValueForKey: and - didChangeValueForKey: won't.

I suspect the real cause of the problem is that there's a setValue: method defined in the superclass that returns something.

If you're going to be using KVO/KVC on your objects, you should probably reconsider whether it's a good idea for your setter/getter methods to use non-default names. Obviously, you can change the name of your property if it clashes with methods in your superclass.

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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