Re: NSBlockOperation with +[sendSynchronousRequest sendSynchronousRequest:...] or async?
Re: NSBlockOperation with +[sendSynchronousRequest sendSynchronousRequest:...] or async?
- Subject: Re: NSBlockOperation with +[sendSynchronousRequest sendSynchronousRequest:...] or async?
- From: Aurélien Hugelé <email@hidden>
- Date: Fri, 21 Jan 2011 08:31:41 +0100
Always use the async API.
For networking, there are *tons* of reasons to avoid your own threading (ie, CPU -> battery consumption) when Apple does all that for your using their Async API (and only one global thread to manage the network)
Look at the free WWDC videos from 2010, this is very well explained.
Aurélien,
Objective Decision Team
On 20 janv. 2011, at 23:51, Rick Mann wrote:
> With the advent of code blocks and NSBlockOperation, it's a lot tidier, and easier, to write code using NSURLConnection, particularly in the presence of multiple operations. The approach is to use an NSBlockOperation and +[NSURLConnection
> sendSynchronousRequest:returningResponse:error:] to synchronously request a resource (which occurs on a separate thread).
>
> The alternative is to use the asynchronous methods, and then manage all the state necessary to keep track of multiple instances of the same request. I prefer the former approach, but does Apple still recommend the async approach? Or is there no real difference between the two?
>
> I'm running on iOS 4.x, on a single-core device, but I don't think these devices will remain single-core for long, and the same question applies to multicore Macs.
>
> Thanks,
> Rick
>
> _______________________________________________
>
> 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
_______________________________________________
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