相关疑难解决方法(0)

iOS:我如何知道某个属性是否符合KVO标准?

Key-Value Observing Programming Guide中,注册键值观察部分说:"Apple提供的框架中的典型属性只有符合KVO标准才会被记录." 但是,我没有在文档中找到任何记录为KVO兼容的属性.你能指点一下吗?

具体来说,我想知道,如果@property(nonatomic,retain) UIViewController *rootViewControllerUIWindow是国际志愿者组织兼容.原因是我正在为iOS <4 添加rootViewController属性,UIWindow并想知道我是否应该使其符合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]; …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c key-value-observing ios4 ios

18
推荐指数
1
解决办法
6656
查看次数