I want to use KVO to be notified when the number of selected cells in a UICollectionView changes. When I tried to subclass UICollectionView
and add a new property nSelectedCells
, I ran into a problem when trying to add the logic that updates nSelectedCells
. There are too many places where the selected cells count can change:
- Programmatically - View:
deselectItemAtIndexPath
,selectItemAtIndexPath
,reloadData
, ... - UI - Controller:
didDeselectItemAtIndexPath
,didSelectItemAtIndexPath
- More?
What would be the best way to keep track of this value. Preferably from within the UICollectionView
subclass.