I have an array of NSNumbers which I would like to use to change the image of a UICollectionView
cell if each of those numbers is equal to the indexPath
row of the collectionView
.
I'm aware that I can use:
if [indexPath row] == 5 {
self.myImage = [UIImage imageNamed:@"120-red.png"];
aCell.imageView.image = self.myImage;
}
for a single value, but how do I do this from an array?
btw. its a dynamic NSMutableArray
which is created from purchased products and stored in NSUserDefaults
. Any help is much appreciated!
You could save your indexes and image names in a dictionary with the keys being NSNumbers.
Then in your dataSource method
When you change the data you need to reload it. Either use:
To reload only the ones you changed,
OR
To reload the whole collection