AFNetworking - batched operations completion block firing before all JSON requests completed

453 views Asked by At

I'm just starting using AFNetworking and have come across an anomaly when using enqueueBatchOfHTTPRequestOperations to batch together 3 AFJSONRequestOperation objects. I've found that occasionally the completionBlock for the queue fires before all of the AFJSONRequestOperation completion blocks have fired. After doing some research it seems this is to do with the AFJSONRequestOperation parsing the response data to JSON which it does in a separate queue meaning the request reports to the queue as finished before the parsing has completed.

My question therefore is - can I instead use AFHTTPRequestOperation objects for my 3 requests, and parse the JSON manually myself within the request completion block? Will this then guarantee that the queue completionBlock will only fire once all requests have completed?

1

There are 1 answers

0
Jonathan Wareham On BEST ANSWER

I changed my code to use AFHTTPRequestOperation instead of AFJSONRequestOperation and parse the JSON manually, and I've been testing the new version for the last couple of days. I've not seen the problem occur once so I think it's safe to say the queue completion block firing before all requests have completed only happens when using AFJSONRequestOperation.