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 (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