andrea-prearo / SwiftExamples

Swift Examples Repository
MIT License
274 stars 122 forks source link

Only a question! #3

Closed noais closed 7 years ago

noais commented 7 years ago

I saw better your code and I don't understand why you did the alteration on "fix-image-scrambling" commit?

Can you explain me why you simple put the avatar as a strong var?

@IBOutlet var avatar: UIImageView!

andrea-prearo commented 7 years ago

Setting avatar as a strong var would create retain cycles when accessing the property inside a closure. The goal of fix-image-scrambling was to improve the behavior of the cell when it gets recycled (override func prepareForReuse()) by:

This should prevent overwriting a cell with the wrong image.

The changes I made are not very efficient and I am planning to implement a better solution soon enough.

noais commented 7 years ago

You right, thank you.