I'm uploading multiple photo's to a server with AFNetworking (POST). It works great, except on iPhone 4/4S where I run into memory issues. The problem is all the payloads are built in advance and fill up memory; request are build much faster then they are sent.
So rater than executing my AFNetworking calls serially, I need to wait for each call to:
self.manager POST:parameters:success:failure: to complete before calling it again. My code is something like this:
iterate over a group of images
[self sendTheImageToTheServer:image completion:{ ok, I'm done. send me the next one now. }];
// sendTheImageToTheServer:image calls self.manager POST:parameters:success:failure:
done
Ideally I'd like to use a dispatch group so I can a be alerted when the last block is done.
Any suggestions would be great.
EDIT: I can't use setMaxConcurrentOperationCount to help with this because all my payloads are built in advance and fill up memory; I use AFNetworking constructingBodyWithBlock to construct the body of my POST. Also, I don't want this to block so I need to be notified when the last image is sent.