Re: Open a panel in secondary thread?
Re: Open a panel in secondary thread?
- Subject: Re: Open a panel in secondary thread?
- From: Gabriel Zachmann via Cocoa-dev <email@hidden>
- Date: Sun, 22 Mar 2020 20:11:03 +0100
>
> Don't know if this helps you but you can look into dispatch_sync
> and dispatch_async.
>
Thanks a lot!
That made things very easy.
I am opening the panel now with this piece of code:
__block NSURL * user_permitted_url;
__block long int result;
// UI stuff must be executed in the main thread
dispatch_sync( dispatch_get_main_queue(), ^(void)
{
result = [self askUserToOpenDirectory: resolvedurl
newURL: & user_permitted_url];
}
);
(where my method askUserToOpenDirectory opens the NSOpenPanel and gets the URL.)
BTW:
just in case others stumble over this:
in my case, I am opening the NSOpenPanel with the directory set to resolvedurl,
for which I am asking permission. So the user is just supposed to click "OK".
So, I thought, I don't need to do anything else;
but it turns out I get permission from the OS really only if I actually get the
URL using
oPanel.URL
, even if it is the same as resolvedurl!
Best regards, Gabriel
_______________________________________________
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