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 14:05:23 +0000
On 29 Oct 2009, at 08:36, DKJ wrote:
I replaced the line:
[downloadIndicator startAnimating];
with this:
NSInvocationOperation *theOp = [[[NSInvocationOperation alloc]
initWithTarget:downloadIndicator
selector:@selector(startAnimating) object:nil] autorelease];
NSOperationQueue *theQ = [[[NSOperationQueue alloc] init]
autorelease];
[theQ addOperation:theOp];
and now it works just the way I want it to.
But am I taking a sledgehammer to a fly? Or have I found (quite by
accident) the best way to do it?
Unless the documentation says specifically that NSProgressIndicator is
thread-safe, the code above is a no-no.
You need to rewrite your code so that the download is asynchronous.
It's either that or periodic calls to a nested event loop, which is
(a) really ugly and (b) error-prone.
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