コレクションノートを観察しようとしています。コードは次のとおりです。
-(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;
}
}
ここで、notes コレクションからオブジェクトを削除するときに、observeValueForKeyPath メソッドを起動する必要があります。
[self.selectedVegetableGarden.notes removeObject:note];
現在、発砲していません!