uml
uml

Reputation: 1189

Observing custom cell

I am trying to add observer (KVO) to observe my custom cell. Once the cell is selected I should receive a notification of the event. My code:

[colMain addObserver:self forKeyPath:@"colMain" options:0 context:NULL];

}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{

    if (keyPath == @"colMain") {
        NSLog(@"cell Selected");
        [self performSelector:@selector(deleteCell) withObject:nil];

    }
}

colMain stands for collectionView. I am not quite sure how to do it cause I don't have customCell as a property otherwise it does not compile. Any ideas?

Upvotes: 0

Views: 116

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

Why not just set a delegate on your collection view and then implement one of these two methods?

[– collectionView:shouldSelectItemAtIndexPath:]

[– collectionView:didSelectItemAtIndexPath:]

Upvotes: 2

Related Questions