• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Issues in specifying the file extensions for NSOpenPanel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issues in specifying the file extensions for NSOpenPanel


  • Subject: Re: Issues in specifying the file extensions for NSOpenPanel
  • From: Corbin Dunn <email@hidden>
  • Date: Wed, 10 Nov 2010 14:50:05 -0800

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

_______________________________________________

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

References: 
 >Issues in specifying the file extensions for NSOpenPanel (From: Sachin Porwal <email@hidden>)
 >Re: Issues in specifying the file extensions for NSOpenPanel (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Documentation Hard Copy?
  • Next by Date: Submitting a web form?
  • Previous by thread: Re: Issues in specifying the file extensions for NSOpenPanel
  • Next by thread: Pause during drawing
  • Index(es):
    • Date
    • Thread