0

I have a UITableViewCell that observes (via KVO) some properties. This only makes sense if the cell is visible. I want to remove this observer when the cell scrolls away, and before prepareForReuse is called.

How can I do this?

cfischer
  • 24,452
  • 37
  • 131
  • 214
  • 1
    I would suggest your datasource should be observing instead of cell observing to the KVO changes, and reload the specific cells depending on the changes. But if your case needs cell to be observing for KVO changes for properties then you can as @Lance suggested "didEndDisplayingCell" method. – Pavan Apr 14 '15 at 23:30

1 Answers1

2

Your table view delegate can implement

- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

and in there you can call a method on the cell to perform the cleanup you want.

Lance
  • 8,872
  • 2
  • 36
  • 47