This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7910383-ios-photos-framework/lessons/3
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7910383-ios-photos-framework/lessons/3
Apple recommends to use the asset localIdentifier instead of a reuseCount, like so:
// Request an image for the asset from the PHCachingImageManager.
cell.representedAssetIdentifier = asset.localIdentifier
imageManager.requestImage(for: asset, targetSize: thumbnailSize, contentMode: .aspectFill, options: nil, resultHandler: { image, _ in
// UIKit may have recycled this cell by the handler's activation time.
// Set the cell's thumbnail image only if it's still showing the same asset.
if cell.representedAssetIdentifier == asset.localIdentifier {
cell.thumbnailImage = image
}
})
Thanks for the tip, freddyf!
Good feedback. For anyone reading. This is Part 1, Section 3 at the 03:15 mark of the lecture.
I started with the Chapter Part 1, lecture 1 of the app and just kept making changes. It blew up on me after completing Lecture 3 with the Lecture 1 version. The reason was due to the Main.storyboard AssetCell having a bad outlet assigned to the checkmark. After I removed that everything worked as expected with no crash. Hopefully someone might find that useful.
@cupofjoe Thank you for the heads up - much appreciated!