Latest | 0.1.0 |
---|---|
Homepage | https://github.com/eladb/CLBlockObservation |
License | MIT |
Platforms | ios 6.0, requires ARC |
Authors |
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, [email protected]
License
CLBlockObservation is available under the MIT license. See the LICENSE file for more info.
Latest podspec
{ "name": "CLBlockObservation", "version": "0.1.0", "summary": "No hassle Objective-C blocks-based KVO library with automatic removal", "homepage": "https://github.com/eladb/CLBlockObservation", "license": "MIT", "authors": { "Elad Ben-Israel": "[email protected]" }, "source": { "git": "https://github.com/eladb/CLBlockObservation.git", "tag": "0.1.0" }, "social_media_url": "https://twitter.com/emeshbi", "requires_arc": true, "source_files": "CLBlockObservation", "platforms": { "ios": "6.0" }, "public_header_files": "CLBlockObservation/*.h" }
Mon, 29 Feb 2016 19:16:04 +0000