Apologies in advanced for my confusion.
I'm trying to do a batch upload of photos in my iPhone application. I have one script that's looping through a user's photos, and then for each photo, calls another script to do the upload. The script that does the upload needs to call back the script that's firing off each of the user's photos to signal success or failure. It's kind of weird, but it's like I need to be able to get the blocking feature of a synchronous call within the loop, but at the same time, the upload script is asynchronous. The code is very involved so I'll try to use pseudocode:
Script one:
foreach (photoNeedsUpload in users photos)
upload the photo via Upload Script
callback hook: successOrFailureUploading (called back by the Upload Script)
Upload Script:
1. Do the upload and then wait for NSURLRequest callbacks:
connectionDidFinishLoading, didFailWithError, etc., etc.
2. Upon getting called back, in turn:
call back Script One appropriately with success/failure signal
My issue is that I'd like to have the asynchronous callbacks so I can check the upload status, but I really need to block for each photo and wait for it to get uploaded. Is there a simple way to do something like this? Should I be putting the thread to sleep, or should I just make the http call synchronous? If so, how to check for success?
I admit that I didn't do my design homework and it's starting to feel like I've created a circular issue for myself!