Re: Asynchronous downloading again
Re: Asynchronous downloading again
- Subject: Re: Asynchronous downloading again
- From: DKJ <email@hidden>
- Date: Sat, 31 Oct 2009 18:50:09 -0700
All of the files have to be downloaded before the app can do anything.
I get the connectionDidFinishLoading delegate method of my one and
only NSURLConnection to call a downloadFinished method at the end of
the synchronous downloads, so the app knows everything is in place and
can start processing the files.
I was worried that having a download connection for each file would
make it more complicated for the app to know when they were all
finished.
And the main thread doesn't seem to be blocked, because my activity
indicator is now spinning quite nicely during the download.
On 2009-10-31, at 18:02 , Roland King wrote:
The whole point of doing things asynchronously is you don't have to
care about waiting for one thing to do another thing, just set up
two NSURLConnections and start them going at the same time. So
unless you need some information from file 1 before starting on file 2
connection1 = [ [ NSURLConnection alloc ] initWithRequest:request1
delegate:self ];
connection2 = [ [ NSURLConnection alloc ] initWithRequest:request2
delegate:self ];
where connection1 and connection2 are instance variables of your
class. Then when you get the callbacks in your delegate just look to
see which connection they are for and deal with them appropriately.
When they are both finished downloading (and don't forget to release
the NSURLConnection(s) when they are) you start doing whatever else
it is you want to do.
Don't understand why you keep trying to go back to synchronous
downloads and you're talking about threads, who says NSURLConnection
uses threads at all. Apart from that, if you read the documentation
for NSURLConnection it tells you all delegate calls take place on
the thread you initiated the download on so, no, even if you did
what you suggested you'd just block the main thread with the
download of file2.
=====================
Hatzic Intellectual Software
Victoria BC, Canada
www.hatzicware.com
_______________________________________________
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