Re: NSOpenPanel runModal on a dispatch
Re: NSOpenPanel runModal on a dispatch
- Subject: Re: NSOpenPanel runModal on a dispatch
- From: Tamas Nagy <email@hidden>
- Date: Sun, 16 Dec 2012 18:20:34 +0100
Unfortunately that doesn't help.
I think the issue should be related to dispatches, because it won't happen if I just call performSelectorOnMainThread...
On Dec 16, 2012, at 6:05 PM, Mike Abdullah <email@hidden> wrote:
>
> On 16 Dec 2012, at 10:45, Tamas Nagy wrote:
>
>> Hey,
>>
>> I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The panel displays, but no files going to be displayed - the circle just spinning on the bottom-left corner. Anyone have an idea what going wrong?
>>
>> Thanks,
>>
>> Tamas
>>
>> dispatch_async(dispatch_get_main_queue(), ^{
>>
>> NSOpenPanel *oPanel = [NSOpenPanel openPanel];
>>
>> NSMutableArray *filetype = [NSMutableArray arrayWithCapacity:0];
>>
>> [filetype insertObject:@"txt" atIndex:0];
>>
>> [oPanel setAllowedFileTypes:filetype];
>> [oPanel setDirectoryURL:[NSURL URLWithString:NSHomeDirectory()]];
>
> This line of code is your problem. +URLWithString: is not an appropriate way to create a URL from a path. +fileURLWithPath:isDirectory: is what you want instead.
>
> +[NSSavePanel setDirectoryURL:] behaves oddly with non-existing paths, as covered at http://www.mikeabdullah.net/pre-populating-nssavepanel.html
>
_______________________________________________
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