Swift Custom Response Serializer is returning images at random

安稳与你 提交于 2019-12-08 13:20:37

Somehow the images get appended at a random order, why?

Because order is not guaranteed for asynchronous requests or blocks dispatched asynchronously.

Instead of appending images into an array, you should key them into a dictionary according to their corresponding page (e.g. pages[i] = image) (by the way, it's easier and more conventional to use for i in 0..<pages.count { ... }).

Or even better, only request the images on demand using AFNetworking's UIImageView category.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!