On Jun 21, 2010, at 7:33 PM, Jens Alfke wrote:

> In general, if you have some kind of background activity that needs to call 
> some AppKit method like this, use -performSelectorOnMainThread:.

If you’re requiring 10.6 or greater, you can use one of these methods as well:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
        // do something on the main thread
}];

or, alternatively:

dispatch_async(dispatch_get_main_queue(), ^{
        // do something on the main thread
});

This can make things much less of a pain when you need to run a method that 
takes something other than an object for a parameter, such as 
stopModalWithCode: (the other options being to write your own method that wraps 
stopModalWithCode: and run that on the main thread, or use NSInvocation).

Charles_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to