Re: Showing activity indicator during data download
Re: Showing activity indicator during data download
- Subject: Re: Showing activity indicator during data download
- From: Alastair Houghton <email@hidden>
- Date: Thu, 29 Oct 2009 16:46:14 +0000
On 29 Oct 2009, at 16:40, DKJ wrote:
On 2009-10-29, at 9:00 , Alastair Houghton wrote:
it's going to be easiest just to use the asynchronous
NSURLConnection approach.
I did implement this, and got it to work. But some of the files I'm
downloading are XML data that needs to be parsed. And the parser
can't start until the file download is complete, which is what made
the synchronous download so appealing.
Since non-XML files are also being downloaded, I can't simply
initiate the XML parsing from the connectionDidFinishLoading
delegate method.
Because? Is the problem here that you need *all* files downloaded
first? In that case, just keep track of what you need to download,
then in your -connectionDidFinishLoading method, test whether you have
everything, and if you have, start your parse.
Alternatively, if the problem is that you're using the same delegate
for multiple NSURLConnections, you just need to keep track of which
one it is that returns the data you need to start parsing.
It might be a little easier to give some advice if you could be more
specific about what you are downloading and why you currently think
this will be a problem for you.
So how to start the parsing? The following seems rather amateurish:
while( !downloadFinished )
[self amuseTheUser];
[self startParsing];
I suspect there's a better way.
Yeah, don't do that.
In non-threaded code it won't work (without nested run loops, and you
*really* don't want to get into that quagmire), and in threaded code
it may still not work because of thread safety issues with your shared
variable.
You *should* be able to do everything you need from the -
connectionDidFinishLoading method.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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