具体来说,我想知道
UIWindow
的@property(nonatomic,retain) UIViewController *rootViewController
是否是KVO-compliant。原因是我正在为iOS < 4添加rootViewController
属性到UIWindow
,想知道我是否应该使其成为KVO-compliant。@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
[super performSelector:@selector(rootViewController)]
和[super performSelector:@selector(setRootViewController:) withObject: rootViewController]
。 - ma11hew28