Hi Rick,

I thought I'd pass along a message from Quinn in Apple's DTS group on this
topic.  Also, fyi, <http://www.lists.apple.com/macnetworkprog> is better for
networking questions

-Ken

Doing your NSConnection stuff synchronously is a mistake, even if
> NSBlockOperation makes it easier.  There are three major issues:


> o resource usage -- Threads are expensive, so having a bunch of threads
> sitting around literally doing nothing is not a great idea.  This is major
> concern on iOS, much less so on Mac OS X.


> o cancellation -- It's hard to implement cancellation in this sort of
> setup.


> o no delegate -- +[NSURLConnection sendSynchronousRequest:...] does not
> provide you with a delegate, which means you can't handle authentication
> challenges.  This is a problem because, even if the HTTP resource itself is
> not protected, you might be behind an authenticating proxy.  On iOS there's
> no avoiding this; you have to handle authentication challenges.  On Mac OS X
> this is only a problem if the existing proxy credentials (in the keychain)
> are wrong.


> You can resolve all of these issues, and stay within the NSOperation
> universe, by using a concurrent operation that manages an async
> NSURLConnection.  The QHTTPOperation class is a good example of this.


> <http://developer.apple.com/library/mac/#samplecode/LinkedImageFetcher/>

<http://developer.apple.com/library/ios/#samplecode/MVCNetworking/>



On Thu, Jan 20, 2011 at 2:51 PM, Rick Mann <rm...@latencyzero.com> 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 (Cocoa-dev@lists.apple.com)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to kenfe...@gmail.com
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to