On Nov 9, 2010, at 9:13 PM, Quincey Morris wrote: > 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.
Some apps do this to allow you to choose folders as though they are types. For example, Xcode lets you add a .framework, and the .framework folders are treated as selectable files. That's why this works this way. UTIs may be a good work around, as Quincey said. corbin > > 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/corbind%40apple.com > > This email sent to corb...@apple.com _______________________________________________ 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