Reputation: 1027
I am new to Reactive Cocoa and having trouble understanding it. But here is how I am using RACObserve & RACSignal. In my viewDidLoad:
[[RACSignal combineLatest:@[RACObserve(self, cellArray)]] subscribeNext:^(id x) {
// I've set a breakpoint here.
}];
I want to trigger the above code/block when I update cellArray (NSMutableArray). I'm getting data via an API and adding the data to my cellArray like this:
[self.cellArray insertObject:item atIndex:x];
Or
[self.cellArray addObject:item];
Am I implementing this properly?
Upvotes: 1
Views: 182
Reputation: 25927
You can't observe insertions/deletions in an array like that. This has been discussed extensively before. Have a look at this solution in RAC's repo. Basically in your case would like:
NSMutableArray *contents = [self mutableArrayValueForKey:"cellArray"];
[contents addObject: item];
Upvotes: 1