¿Qué hay de malo en este observeValueForKeyPath: ofObject: change: context: implementación?
En mi subclase UIScrollView, estoy observando cambios en el marco:
[self addObserver:self forKeyPath:@"frame" options:0 context:NULL];
MiobserveValueForKeyPath:ofObject:change:context:
la implementación es la siguiente:
- (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
}
}
Pero obtengo una excepción con este código:
*** 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'
¿Significa que UIScrollView implementaobserveValueForKeyPath:ofObject:change:context:
pero arroja la excepción anterior?
Si es así, ¿cómo puedo implementar correctamenteobserveValueForKeyPath:ofObject:change:context:
para poder manejar mis cambios interesados y darle a la superclase la oportunidad de manejar sus cambios interesados.