KVC NSKeyValueChangeRemoval Not Being Observed
I am trying to observe a collection notes. Here is the code:
-(void) registerNotesHeaderViewChangeNotification
{
[self.selectedVegetableGarden addObserver:self forKeyPath:@"notes"
options:NSKeyValueObservingOptionNew | NSKeyValueChangeRemoval
context:nil];
}
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
MyVegetableGarden *vegGarden = (MyVegetableGarden *) object;
if([vegGarden.notes count] > 0)
{
self.tableView.tableHeaderView = [self createSharingView];
}
else
{
self.tableView.tableHeaderView = nil;
}
}
Now, I want that when I remove an object from the notes collection it
should fire the observeValueForKeyPath method.
[self.selectedVegetableGarden.notes removeObject:note];
Currently, it is not firing!
No comments:
Post a Comment