Which delegate of NSURLConnection to use?

You're using sendSynchronousRequest:returningResponse:error: which does not call any delegates methods because it doesn't need to: when you call it, the main thread stops until the request is finished and you get the response.

You're using sendSynchronousRequest:returningResponse:error: which does not call any delegates methods because it doesn't need to: when you call it, the main thread stops until the request is finished and you get the response. If you want to make an asynchronous request, use connectionWithRequest:delegate:. I recommend to always do asynchronous responses since the synchronous request blocks the main thread and your UI can't respond during that time.

Animations will become interrupted. Scrolling becomes jerky. If you do want to use synchronous requests you should do it in a background thread.

The -sendSynchronousRequest:returningResponse:error: method blocks the main-thread (whenever it runs on the main-thread of course, since it's possible to run this method from any other thread, but I believe this is not recommended). The methods using the delegates are asynchronous, the methods will fire and the results will (at some point in the future) be returned in the delegate methods. This gives the user a more smooth experience, since the main-thread will not be blocked.

Edit: personally I hardly ever use the -sendSynchronousRequest:returningResponse:error: method for the aforementioned reasons. Most of the time I use this method when I need to build something quickly, for example a proof-of-concept. I guess one could use the method for small downloads, yet if a timeout occurs (because for some reason the server is down) the whole UI will be blocked for (I believe) 2 minutes, which would be very annoying for the enduser.

I am implementing asynchronous request in separate class but delegate methods not called. €“ – Rams Jun 4 at 7:49 You should show more code so we can see why the delegate isn't being called. Did you set breakpoints?

As far as I can see, the delegate methods should be called in your example, though perhaps it won't download anything (the NSMutableData object might not be initialized). – Wolfgang Schreurs Jun 5 at 19:16.

An excellent demonstration to clarify your doubt is available in apple sample apps. You can refer Apple's sample app for a better understanding of asynchronous request and parsing data in separate class.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions