Registering for Key-Value Observing, calling super?

  • The Apple docs here:
    <http://developer.apple.com/documentation/Cocoa/Conceptual/
    KeyValueObserving/Concepts/KVOBasics.html#//apple_ref/doc/uid/20002252/
    BAJEAIEE
    >

    Have in listing 2 this example:

    - (void)observeValueForKeyPath:(NSString *)keyPath
                  ofObject:(id)object
                            change:(NSDictionary *)change
                          context:(void *)context
    {
        if ([keyPath isEqual:@"openingBalance"]) {
        [openingBalanceInspectorField setObjectValue:
            [change objectForKey:NSKeyValueChangeNewKey]];
        }
        // the same change
        [super obeserveValueForKeyPath:keyPath
                    ofObject:object
                    change:change
                    context:context];
    }

    Notice the call to super.  1) obeserveValueForKeyPath is a typo and
    should be observeValueForKeyPath 2) should one really always call super?
    If I do, I get this error logged:

    2004-08-26 01:52:16.501 Futzing[1202] *** -observeValueForKeyPath:
    ofObject:change:context: only defined for abstract class.  Define -
    [PLUpcomingController observeValueForKeyPath:ofObject:change:context:]!

    and other bad things happen.

    Thanks!
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • On Aug 25, 2004, at 11:51 PM, Sean McBride wrote:

    > Notice the call to super.  1) obeserveValueForKeyPath is a typo and
    > should be observeValueForKeyPath 2) should one really always call
    > super?
    >
    You only need to call super if the superclass is itself observing, for
    example in a subclass of NSView or of NSArrayController.

    mmalc
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.