Re: The current preferred method for fetching HTTP URLs for IOS
Re: The current preferred method for fetching HTTP URLs for IOS
- Subject: Re: The current preferred method for fetching HTTP URLs for IOS
- From: Marco Tabini <email@hidden>
- Date: Fri, 09 Mar 2012 14:37:36 -0500
> I've been reading (and trying out) a few approaches on HTTP communication using GCD to do a dispatch_sync or dispatch_async to a dispatch queue or using an NSURLRequest.
>
> Which of these is the preferred method for ingesting strings from HTTP URLs on iOS? Are there any plusses to one over the other?
FWIW, my view is that it depends on what your requirements are. For a simple request, you can go with an [NSString stringWithContentsOfURL] wrapped in a call to dispatch_async to avoid blocking the main thread.
If you require a more sophisticated level of control over the transaction, NSURLRequest is obviously a better choice. Personally, I almost always find this to be the case, if only because I can cancel a request if necessary.
As for running an NSURLRequest on a thread other than the main thread, I've found very little use for it unless you need the download to continue after your app has been pushed into the background. Otherwise, it just introduces an additional level of complexity that I prefer to avoid if I can :-)
—Mt.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden