CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

JFObservableArray 0.1.0

JFObservableArray 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Jamie Forrest.



Usage

To run the tests, clone the repo, and run pod install from the Example directory first.

Installation

Usage

JFObservableArray is a KVO-compliant array wrapper that informs observers of changes to the array's underlying structure. Clients can set up KVO as follows:

JFObservableArray *array = [JFObservableArray new];
[array addObserver:self forKeyPath:@"self" options:NSKeyValueObservingOptionNew context:nil];

And the changes can be observed as follows:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    switch ([change[NSKeyValueChangeKindKey] integerValue]) {
        case NSKeyValueChangeInsertion: {
            // data was inserted at the indexes in change[NSKeyValueChangeIndexesKey]
            break;
        }
        case NSKeyValueChangeRemoval: {
            // data was removed at the indexes in change[NSKeyValueChangeIndexesKey]
            break;
        }
        case NSKeyValueChangeReplacement: {
            // data was replaced at the indexes in change[NSKeyValueChangeIndexesKey]
            break;
        }
        default:
            break;
        }
}

Author

Jamie Forrest

License

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