开发者

NSURLConnection with delegate vs initWithContentsOfURL: with Grand Central Dispatch

I am writing an application which downloads very much JSON data from the internet. My app needs to parse this JSON data and afterwards return the retrieved objects to a self-made delegate.

Now I was wondering if I could b开发者_C百科etter use NSURLConnection or a combination of Grand Central Dispatch's dispatch_async with initWithContentsOfURL: (using GCD to prevent hanging).

Using Grand Central Dispatch is much easier to implement, especially because I don't need delegates nor NSMutableData nor all other variables that are used temporarily. But of course, everything with pros has its cons.

What are the advantages of NSURLConnection over initWithContentsOfURL with GCD?


  1. You can target iOS 3.x.
  2. You can use a customized NSURLRequest that, e.g., asks for the results of an HTTP POST—the NSData factory only does basic GET when passed an HTTP URL.
  3. You can track the download's progress with your NSURLConnection delegate.

That's it off the top of my head. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜