MLAKeyValueObserverCenter allows you to use K.V.O as you will do with NSNotificationCenter.
Its purpose is to make K.V.O notification more flexible :
- Selectors and blocks as callback
- Safe remove observer
- Allow retrieve observers for a given object’s keyPath
[[MLAKeyValueObserverCenter defaultCenter] addObserver:self
selector:@selector(nameDidChange:)
keyPath:@"name"
object:self.person];
- (void)nameDidChange:(NSDictionary *)change
{
// implementation go here
}
[[MLAKeyValueObserverCenter defaultCenter] removeObserver:self];
id observer = [[MLAKeyValueObserverCenter defaultCenter] addObserverForKeyPath:@"name"
object:self.person
usingBlock:^(NSDictionary *changes) {
NSLog(@"Name has changed !");
}];