Could someone provide a one-line example of using ReactiveCocoa abstractions to achieve something like this:
// pseudo-code
NSMutableArray *array = @[[] mutableC
The swift equivalent for Chris' solution:
let signal = self.object.rac_valuesAndChangesForKeyPath("property", options: NSKeyValueObservingOptions.New | NSKeyValueObservingOptions.Old, observer:self.object)
signal.subscribeNext { (object) -> Void in
if let tuple = object as? RACTuple {
var wholeArray = tuple.first as? NSArray
var changeDictionary = tuple.second as? NSDictionary
}
}
Also make sure you change your contents property in KVO compliant ways.
// This is wrong and wont send values to RAC signals
[self.contents addObject:object];
// This is correct and will send values to RAC signals
NSMutableArray *contents = [account mutableArrayValueForKey:@keypath(self, contents)];
[contents addObject:object];
Edit: To make things more clear, put the name of your array in place of property. For example:
lazy var widgets:NSMutableArray = NSMutableArray()
let signal = self.rac_valuesAndChangesForKeyPath("widgets", options: NSKeyValueObservingOptions.New | NSKeyValueObservingOptions.Old, observer:self)