title: How to make program wait for asynchronous NSURLConnection to finish before proceeding with next command?
body: <p>How can I make my program wait for an asynchronous NSURLConnection to finish before going to the next line of code?</p>
  
  <pre><code>SetDelegate *sjd= [SetDelegate alloc];
  NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:post delegate:sjd];
  [connection start];
  </code></pre>
  
  <p>This is how I start the connection and I handle the data received in the delegate but I want to wait for the connection to end before proceeding mainly because this is in a for loop and it has to run for each element in my database.</p>
  
  <p>I need to put data from the phones database to a remote database and after the data was successfully put in the data in the phones database is deleted. I am going through each element in the phone's database and start a connection that's why I don't see how the next stuff can be done from the loop. I'm a beginner when it comes to objective-c programming so I'm not sure if this is the right way or not to do it</p>
  
  <p>Making the call synchronous is not an option because it blocks the program and i have a progress bar that should show.</p>