If I have the following data model:
Model
- subModels (NSMutableArray * of type SubModel)
SubModel
- text
- createdAt
is it possible to use KVO to observe changes on the parent Model
class and still receive changes notifications for properties on relationship models?
Using ReactiveCocoa
, what I'm trying to accomplish would look something like this:
self.model = [Model new];
self.model.subModels = [NSMutableArray array];
SubModel *subModelOne = [SubModel new];
[self.model mutableArrayValueForKeyPath:@"subModels"] addObject:subModelOne];
[RACObserve(self, model) subscribeNext:^(id next){
NSLog(@"%@", next);
}];
subModelOne.text = @"Lollipop, lollipop, oh lolli lolli lolli lollipop!";
What I want to happen is I would get a next event from initializing model.subModels
to an empty array, one from adding a sub model to the relationship, and finally one from setting subModelOne.text
. Essentially I want all subproperties, submodels, etc, KVO notifications to propagate up the chain but I'm not sure how to accomplish that task.