Hi everybody,

What would be the most efficient way to download data without blocking the UI 
(I'm targeting old iPhone/iPod devices) ?

- using a NSURLConnection seams nice, but as it calls its delegate 
(-connection:didReceiveData:) on the main thread, it has to take a lock on the 
main thread some times, hasn't it?

- then how about using NSURLConnection in background threads, like with 
+[NSThread detachNewThreadSelector:toTarget:withObject:] ?

- as I would rather avoid loading lots of thing simultaneously, I would like to 
use a queue. NSOperationQueue seams adequate, and it would do the asynchronous 
thing for me. I such case, directly using -[NSData 
initWithContentOfURL:options:error] in a -[NSOperation main]  seams very 
straight forward ! No delegate to setup, very little code to write.
But... Some people during last tech talk told me to avoid using NSOperation to 
do high latency operations (such as network operations). 
Why is that ? Does someone has an explanation ?

My only guess is that there would be a lot of context switch between threads 
for nothing because the thread dealing with the network would be almost 
constantly idle. But, in that case using a NSURLConnection in a thread via - 
detachNewThreadSelector:toTarget:withObject: would be no better than using 
NSOperation. 

In conclusion, should I absolutely avoid putting any loading in background 
thread and rely only on NSURLConnection in the main thread, or are 
NSOperationQueue and NSData initWithContentOfURL somehow compatible and not too 
harmful ? (other ideas welcome...)


Thanks!
Rafael_______________________________________________

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