Re: NSThread and UI
Re: NSThread and UI
- Subject: Re: NSThread and UI
- From: "Bruce Johnson" <email@hidden>
- Date: Sun, 20 Jul 2008 14:25:56 -0700
AppKit stuff isn't thread safe. AppKit stuff is usually the user
interface stuff (like Progress bars) So that should be run on the main
thread, something like:
> [NSThread detachNewThreadSelector:@selector(convert)
> toTarget:self
> withObject:nil];
>
> - (void) convert {
>
>
> if (...) {
> NSRunCriticalAlertPanel(...);
> }
>
> int i;
> for(i = 0; i < 10; i++) {
> [self performSelectorOnMainThread: @selector(updateProgressBarWithValue:) withObject: [NSNumber numberWithInt: i waitUntilDone: NO]]
> ...
> }
>
> [progressIndicator stopAnimation:self];
> }
- (void) updateProgressBarWithValue: (NSNumber *) aNumber
{
[progressIndicator setDoubleValue: [aNumber doubleValue]]];
}
or some such...
--
----
Bruce Johnson
email@hidden
_______________________________________________
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