Re: Problem with stopModalWithCode on a different thread
Re: Problem with stopModalWithCode on a different thread
- Subject: Re: Problem with stopModalWithCode on a different thread
- From: Charles Srstka <email@hidden>
- Date: Mon, 21 Jun 2010 21:56:48 -0500
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 (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