Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

jam/CLBlockObservation

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLBlockObservation

Version Platform

No hassle Objective-C blocks-based KVO library with automatic removal

There are so many KVO libraries out there. Couldn't find one that supports both blocks and automatic removal of observers. And that's usually what I need. Just want to bind stuff around.

Installation

CLBlockObservation is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "CLBlockObservation"

Usage

Usage is straightforward. I would recommend including <NSObject+CLBlockObservation.h> in your .pch file.

[observee addObserver:observer keyPath:@"p1" block:^(id oldValue, id newValue) {
  NSLog(@"do something great!");
}];

There's also support for observing multiple keypaths:

[observee addObserver:observer keyPaths:@[ @"p1", @"p2" ] block:^{
  NSLog(@"be awesome!");  
}];

Tests

There's an XCTest project in this repository. It contains a few tests that verify the lifetime management of the observation and a good sample reference.

There's a script that runs the tests from command line:

$ clone https://github.com/eladb/CLBlockObservation
$ cd CLBlockObservation/Tests
$ ./run-tests.sh

Author

Elad Ben-Israel, elad.benisrael@gmail.com

License

CLBlockObservation is available under the MIT license. See the LICENSE file for more info.

About

No hassle Objective-C blocks-based KVO library with automatic removal

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.