开发者

observeValueForKeyPath not being called

I have a ViewController creating an instance of a UIView, and then I register an observer with the instance, such that

logoAnimation = [[MainLogoAnimation alloc] init];
[logoAnimation addObserver:self forKeyPath:@"patrocinioDidLoad" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];

then, in the same file, I have:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
 NSLog(@"%@ \n %@ \n %@ \n ",keyPath,object,change);
}

But, although I have checked and double-checked that logoAn开发者_如何学编程imation.patrocinioDidLoad has changed, observeValueForKeyPath never gets called...

Am I missing something?

Thanks for the help!

Antonio


Solved it: I was setting patrocinioDidLoad in logoAnimation directly, without using standard getters and setters. In logoAnimation,

patrocinioDidLoad = YES;

didn't work, whereas

self.patrocinioDidLoad = YES;

did!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜