• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSThread and UI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSThread and UI (From: Torsten Curdt <email@hidden>)

  • Prev by Date: Re: newbie question: NSURLConnection delegation and "method instance"
  • Next by Date: Re: Documentation on changing dock icon programmatically?
  • Previous by thread: NSThread and UI
  • Next by thread: Re: NSThread and UI
  • Index(es):
    • Date
    • Thread