To run the tests, clone the repo, and run pod install
from the Example directory first.
JFObservableArray
is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "JFObservableArray"
JFObservableArray
is a KVO-compliant array wrapper that informs observers of changes to the array's underlying structure. Over time the class will support more and more of the NSMutableArray
interface. Clients can set up KVO as follows:
JFObservableArray *array = [[JFObservableArray alloc] initWithArray:@[]];
[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;
}
}
Jamie Forrest
JFObservableArray is available under the MIT license. See the LICENSE file for more info.