Skip to content

dclelland/NSObject-KVOBlocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSObject-KVOBlocks

Real basic block-based KVO using associated objects. Based on Stephan Leroux's KVO-Blocks pod.

Subscribes to NSKeyValueObservingOptionNew and NSKeyValueObservingOptionOld with a nil context.

✓ Set a block!

[self.object setObserverBlock^(NSDictionary *change) {
    NSLog(@"old value: %@", change[NSKeyValueChangeOldKey]);
    NSLog(@"new value: %@", change[NSKeyValueChangeNewKey]);
} forKeyPath:NSStringFromSelector(@selector(aSelector))];

✓ Remove a block!

[self.object setObserverBlock:nil forKeyPath:NSStringFromSelector(@selector(aSelector))];

Full API:

NSObject (KVOBlocks)

- (void)setObserverBlock:(KVOBlock)block forKeyPath:(NSString *)keyPath;
- (KVOBlock)observerBlockForKeyPath:(NSString *)keyPath;

About

Simple block-based KVO using associated objects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published