Qu'est-ce qui ne va pas avec observerValueForKeyPath: ofObject: change: context: implementation?

Dans mon UIScrollView sous-classe, je suis en observant cadre des changements:

[self addObserver:self forKeyPath:@"frame" options:0 context:NULL];

Mon observeValueForKeyPath:ofObject:change:context: mise en œuvre est comme suit:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if (object == self && [keyPath isEqualToString:@"frame"]) {
        [self adjustSizeAndScale];
    }
    if ([UIScrollView instancesRespondToSelector:@selector(observeValueForKeyPath:ofObject:change:context:)]) {
        [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; //Exception
    }
}

Mais j'obtiens une exception avec ce code:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<WLImageScrollView: 0x733a440; baseClass = UIScrollView; frame = (0 0; 320 416); clipsToBounds = YES; layer = <CALayer: 0x7346500>; contentOffset: {0, 0}>: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: frame
Observed object: <WLImageScrollView: 0x733a440; baseClass = UIScrollView; frame = (0 0; 320 416); clipsToBounds = YES; layer = <CALayer: 0x7346500>; contentOffset: {0, 0}>
Change: {
    kind = 1;
}
Context: 0x0'

Signifie-t-il UIScrollView implémente observeValueForKeyPath:ofObject:change:context: mais jette l'exception ci-dessus?

Si oui, comment puis-je mettre en œuvre correctement observeValueForKeyPath:ofObject:change:context: de sorte que je peux gérer mon intéressés changements et de donner de la superclasse une chance de traiter ses intéressées changements?

source d'informationauteur an0