splinesoft/SSDataSources — pull request #28 by andrewsardone (2014-04-04 00:02:57+00:00)
Title: Add array data source that receives updates via KVO

This pull request adds a new object, [`SSArrayKeyPathDataSource`][akp]. I think the name sucks, but I like what it does.

You initialize this object with some object and key path, and `SSArrayKeyPathDataSource` will monitor the targeted `NSArray` for changes and keep the `UITableView`/`UICollectionView` up to date. It's subtllely different from [`SSArrayDataSource`][ads] – it allows changes to bubble up to the view while users solely manipulate an array of data.

Through the magic of [KVO], any manipulation through the collection's proxy object will result in row insertions/deletions/updates – no need to explicitly send a message to `SSArrayKeyPathDataSource`:

```objc
self.department = [Department new];
self.dataSource = [[SSArrayKeyPathDataSource alloc] initWithSource:self.department
keyPath:@"employees"];

// someone, somewhere (think via the UI *or* via a background
// service), adds a new employee
NSMutableArray *employees = [self.department mutableArrayValueForKey:@"employees"];
[employees addObject:@"Shelley T. Bunny"];

// The UITableView/UICollectionView tied to SSArrayKeyPathDataSource
// inserts a new row without an explicit…
// [self.dataSource appendItem:@"Shelley T. Bunny"];
```

It's not for every scenario, but I find many situations where I just want to manipulate an array and have those changes bubble up.

[akp]: https://github.com/andrewsardone/SSDataSources/blob/3409d77a3b7547549df9a647f341955261d6ac5c/SSDataSources/SSArrayKeyPathDataSource.h
[ads]: https://github.com/splinesoft/SSDataSources/blob/24fde31fa67e30c878df294fb5e50c52ddedcbc6/SSDataSources/SSArrayDataSource.h
[KVO]: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyValueObserving/Articles/KVOCompliance.html#//apple_ref/doc/uid/20002178-BAJEAIEE