UIViewController
子类上有一个属性,当视图变为可见时该属性发生更改。 (A组停止是空的)。我实现KVC/KVO如下:为什么KVO观察者在观察无序对多关系时看到空的NSKeyValueChangeNewKey?
- (void)viewWillAppear:(BOOL)animated {
[self willChangeValueForKey:@"anticipatedIndexPaths" withSetMutation:NSKeyValueSetSetMutation usingObjects:_anticipatedIndexPaths];
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
assert([_anticipatedIndexPaths count]);
[self didChangeValueForKey:@"anticipatedIndexPaths" withSetMutation:NSKeyValueSetSetMutation usingObjects:_anticipatedIndexPaths];
}
该类的子类是观察本身@"anticipatedIndexPaths"
,但NSKeyValueChangeNewKey
值时观测NSKeyValueChangeReplacement
始终是一个空集。是什么赋予了?
好想,但是,我是。 'self addObserver:self forKeyPath:@“expectedIndexPaths”options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld | NSKeyValueObservingOptionInitial context:nil];' – Sam 2013-04-11 15:47:10