iOS: Como sei se uma propriedade é compatível com KVO?
No Guia de programação de observação de valores-chave, a seção Registro para observação de valor-chave diz "Normalmente, as propriedades nas estruturas fornecidas pela Apple só são compatíveis com KVO se estão documentadas como tal." Mas não encontrei nenhuma propriedade na documentação documentada como compatível com KVO. Você poderia me indicar algumas?
Especificamente, eu gostaria de saber se o@property(nonatomic,retain) UIViewController *rootViewController
doUIWindow
é compatível com KVO. O motivo é que estou adicionando orootViewController
propriedade paraUIWindow
para iOS <4 e quero saber se devo torná-lo compatível com KVO.
@interface UIWindow (Additions)
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0
@property (nonatomic, retain) UIViewController *rootViewController;
#endif;
@end
@implementation UIWindow (Additions)
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0
@dynamic rootViewController;
- (void)setRootViewController:(UIViewController *)newRootViewController {
if (newRootViewController != _rootViewController) {
// Remove old views before adding the new one.
for (UIView *subview in [self subviews]) {
[subview removeFromSuperview];
}
[_rootViewController release];
_rootViewController = newRootViewController;
[_rootViewController retain];
[self addSubview:_rootViewController.view];
}
}
#endif
@end