Re: Issues in specifying the file extensions for NSOpenPanel
Re: Issues in specifying the file extensions for NSOpenPanel
- Subject: Re: Issues in specifying the file extensions for NSOpenPanel
- From: Quincey Morris <email@hidden>
- Date: Tue, 9 Nov 2010 21:13:18 -0800
On Nov 9, 2010, at 07:00, Sachin Porwal wrote:
> In my application I need to choose only dmg files, so I am using
> NSOpenPanel with the following code snippet.
> But the NSOpenPanel is also allowing me to choose the folders having
> the extension '.dmg'.
>
> Ideally NSOpenPanel should allow me to choose only dmg files not
> folders ? Is this behavior as designed ?
Presumably, since this is mature API, it's behaving as designed. You can get the behavior you want by using a panel delegate to disable choosing directories.
However, a better choice might be specify your desired files by UTI rather than extension. ('kUTTypeDiskImage' is the UTI for disk images.) You simply pass the UTI in place of the extension. That should work without a panel delegate.
Note also that 'runModalForDirectory:...' is deprecated in 10.6. The correct way is to use 'setAllowedFileTypes:' and 'runModal:'.
_______________________________________________
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