MainakChoudhury
MainakChoudhury

Reputation: 59

NSURLConnection (initWithRequest vs sendAsyncRequest)

If both initWithRequest and sendAsyncRequest are Asynchronous ways of connections then whats the major difference ?

Other than completion Handler and Queue concept in sendAsyncReq what else ? Which 1 is more advantageous ??

Upvotes: 0

Views: 143

Answers (1)

Rob
Rob

Reputation: 437552

The sendAsynchronousRequest is simpler and easier to use, saving you from implementing NSURLConnectionDataDelegate and NSURLConnectionDelegate methods. But if you need richness of delegate approach (e.g. challenge-based authentication, need cancelable requests, etc.), then sendAsynchronousRequest is not up to the job.

If targeting iOS 7 and later, consider NSURLSession, instead, too. You can enjoy simplicity of block-based networking and still enjoy delegate methods if and when needed. Also requests are always cancelable. It also opens new opportunities (e.g. background sessions that continue operating even if your app is no longer active).

Upvotes: 1

Related Questions