I\'m using UICollectionView
in an app that is displaying quite a lot of photos (50-200) and I\'m having issues getting it to be snappy (as snappy as Photos app for
I think that approach #3 is the best way to go, and I think I may have spotted the bug.
You're assigning to @image
, a private variable for the whole collection view class, in your operation block. You should probably change:
@image = UIImage.imageWithContentsOfFile(image_path)
to
image = UIImage.imageWithContentsOfFile(image_path)
And change all the references for @image
to use the local variable. I'm willing to bet that the problem is that every time you create an operation block and assign to the instance variable, you are replacing what is already there. Due to some of the randomness of how the operation blocks are dequeued, the main queue async callback is getting the same image back because it is accessing the last time that @image
was assigned.
In essence, @image
acts like a global variable for the operation and async callback blocks.