0

I am trying to make a view controller an observer of a property (an enum) of one of its child view controllers. The view controller whose property I am trying to access is stored in an NSArray. It seems that I cannot do something like this:

[[NSNotificationCenter defaultCenter] addObserver:self forKeyPath:@"[[noteControllers objectAtIndex:1] currentAnimationStatus]" options:NSKeyValueObservingOptionNew context:nil];

so how do I observe the currentAnimationStatus property?

1 Answers1

1

Something like this

UIViewController *controller = [noteControllers objectAtIndex:1];
[controller addObserver:self
             forKeyPath:@"currentAnimationStatus"
                options:NSKeyValueObservingOptionNew
                context:nil];

You should get callback to

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
Adithya
  • 4,545
  • 3
  • 25
  • 28