How to make program wait for asynchronous NSURLConnection to finish before proceeding with next command?

后端 未结 6 1793
日久生厌
日久生厌 2021-02-01 09:10

How can I make my program wait for an asynchronous NSURLConnection to finish before going to the next line of code?

SetDelegate *sjd= [SetDelegate alloc];
NSURLC         


        
6条回答
  •  遇见更好的自我
    2021-02-01 09:36

    You say you want to wait for an asynchronous call to complete, so I'm assuming you're calling the code you posted up in a separate thread.

    I would recommend having a look at the new sendAsynchronourRequest method. I've posted up an example of how you can wrap this up in a class which would inform its delegate when the connection has completed / timed out / failed. I'm only referring you to this post because it sounds like you're trying to achieve something very similar to what I was at the time, and this DownloadWrapper class worked flawlessly for me. It's new in iOS5, mind you.

提交回复
热议问题