Re: Data downloading performance
Re: Data downloading performance
- Subject: Re: Data downloading performance
- From: Rafael Cerioli <email@hidden>
- Date: Sat, 17 Jul 2010 01:36:07 -0400
Le 16 juil. 2010 à 18:56, Kyle Sluder a écrit :
> On Jul 16, 2010, at 3:46 PM, Rafael Cerioli <email@hidden> wrote:
>
>> 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?
>
> No. Read up on NSRunLoop.
I guess I had something wrong, NSURLConnection does not do anything in a background thread. It just operates in the main thread but "asynchronously" thanks to the run loop.
Quote from NSURLConnection class reference :
"At creation, a connection is scheduled on the current thread (the one where the creation takes place) in the default mode"
That means, there is a lot of work done in the main thread. Even if the connection is not scheduled in the runloop "tracking" mode (for the UI), I guess the app would slow down at some point.
Isn't it better to use -[NSData initWithContentOfURL:] synchronous load method in background thread ?Or is there something wrong about that kind of use ?
By the way, I never seen any bug about NSURLConnection running in background threads on iPhone OS.
>
>>
>> - then how about using NSURLConnection in background threads, like with +[NSThread detachNewThreadSelector:toTarget:withObject:] ?
>
> Don't do this. NSURLConnection's synchronous API is buggy, as a web search will tell you.
>
> --Kyle Sluder
>>
_______________________________________________
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