Latest 0.1.0
Homepage https://github.com/jamieforrest/JFObservableArray
License MIT
Platforms ios 7.0, requires ARC
Authors

Version
License
Platform

Usage

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

Installation

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

pod "JFObservableArray"

Usage

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;
        }
}

Author

Jamie Forrest

License

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

Latest podspec

{
    "name": "JFObservableArray",
    "version": "0.1.0",
    "summary": "JFObservableArray is a KVO-compliant array wrapper that informs observers of changes to the array's underlying structure.",
    "description": "                        `NSMutableArray` is not KVO-compliant, meaning that you cannot observe changes to the underlying structure of the array. `JFObservableArray` adds KVO-compliance to `NSMutableArray`, informing clients of inserted, replaced, and removed objects in the array. This is useful, for example, in cases where you might need to bind a view in the UI to a list of objects (e.g., `UITableView`).n",
    "homepage": "https://github.com/jamieforrest/JFObservableArray",
    "license": "MIT",
    "authors": {
        "Jamie Forrest": "[email protected]"
    },
    "source": {
        "git": "https://github.com/jamieforrest/JFObservableArray.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/jamieforrest",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes"
}

Pin It on Pinterest

Share This