NSThread and UI
NSThread and UI
- Subject: NSThread and UI
- From: Torsten Curdt <email@hidden>
- Date: Sun, 20 Jul 2008 23:01:59 +0200
AFAIU accessing UI elements from within an NSThread is a big no-no.
So in the following naive code I would have to either wrap the calls
to the progressIndicator object through a performSelectorOnMainThread
or could send NSNotifications to update it on the main thread. But
looking around the net I haven't seen any example where either of both
approaches is being used. Did I just not look at the right places?
I am also wondering whether using NSRunCriticalAlertPanel() in the
thread is OK or not.
cheers
--
Torsten
[NSThread detachNewThreadSelector:@selector(convert)
toTarget:self
withObject:nil];
- (void) convert {
[progressIndicator setMaxValue:10];
[progressIndicator startAnimation:self];
if (...) {
NSRunCriticalAlertPanel(...);
}
int i;
for(i = 0; i < 10; i++) {
[progressIndicator setDoubleValue:(double)i];
[progressIndicator displayIfNeeded];
...
}
[progressIndicator stopAnimation:self];
}
_______________________________________________
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