문제

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 better 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. :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top