Data downloading performance
Data downloading performance
- Subject: Data downloading performance
- From: Rafael Cerioli <email@hidden>
- Date: Fri, 16 Jul 2010 18:46:55 -0400
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 (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