Challenge: A Better Way to Download Images |

This is a companion discussion topic for the original entry at

Not sure why we need to capture self here- don’t think we are leaking memory. Can you expand on that?

hi Bhaskar! John Sundell explains in this article about capturing self in escaping closures so it doesn’t “disappear while the closure is pending execution” and gives alternatives.

on iOS 14.4 (both simulator and device) / Xcode 12.3, am getting scattershod images in the view with challenge results. It is same behavior with both the edited challenge and the “final” 05-challenge-a-better-way-to-download-images/final/Concurrency version/

the first screen on app startup has all visible images loaded, and scrolling is always smooth. However, scrolling cells off-screen has them blank mostly, and “new” cells are always mostly blank, with only a couple visible. if rapid scrolling is performed through whole range, can get all cells to be blank.

an experiment with changing the qos to .userInitiated let to slightly better results, but still can make scrolled-in cells mostly appear blank.

Could this have something to do with cell reuse limits?

For anyone else noticing this, in 06-the-right-way-to-download-images (the next section) there is a mention at the end of video why things may appear this way (this implementation is without starting or cancelling download requests or caching downloads, etc.). And it is further mentioned that Operation-s are used to do this in later part of course.

1 Like