Reputation: 607
I have a question regarding AFNetworking..:
I'm setting cell's image with setImageWithURL:
but found out that requests are sent in some random order, i.e. i'm setting images for cells #1,2,3,4 and request for image #3 will be sent at first.
same scenario, I've noticed that sometimes two connections are opened (often one of them has "Client closed connection" status before receiving entire response, but now always).
Is there an explanation for such behaviour ?
Upvotes: 0
Views: 293
Reputation: 63984
As noted in the documentation for this method, all this processing is done asynchronously. So some requests may start or finish at different times. Depending on the image's file size or the servers latency they may start or finish at different times.
If you wanted to set the images in order you could hold back on setting the cell's image until the previous cell was finished within the success block of setImageWithURLRequest:placeholderImage:success:failure:
described here.
You could also manipulate AFHTTPClient and AFImageResquestOperation to only download one image at a time with NSOperationQueue's maxConcurrentOperationCount
method.
Upvotes: 2