Using iOS6's awesome new UICollectionView
how am I able to delete all of the UICollectionViewCell
objects in a big loop?
Say I've loaded all my data into it already, I hit refresh, I want to delete everything currently in there, then just call my stuff again.
I've found deleteItemsAtIndexPaths
which takes an NSArray
, so how can I get all items into it?
Turns out I can use
deleteSections
and pass aNSIndexSet
through to it, making a range of0,0
and it'll delete the one and only section.I could probably just use
indexSetWithIndex
but when I did my app crashed.The proper way of clearing out a UICollectionVew is to simply clear the data source and then reload the collection view.
So if your data source was an array:
Boom, you're cleared out.