Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 logoAnimation.patrocinioDidLoad has changed, observeValueForKeyPath never gets called...

Am I missing something?

Thanks for the help!

Antonio

like image 823
Antonio Avatar asked Apr 28 '10 10:04

Antonio


1 Answers

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!

like image 194
Antonio Avatar answered Oct 17 '22 08:10

Antonio