Re: NSOpenPanel & NSFileTypeForHFSTypeCode
Re: NSOpenPanel & NSFileTypeForHFSTypeCode
- Subject: Re: NSOpenPanel & NSFileTypeForHFSTypeCode
- From: Corbin Dunn <email@hidden>
- Date: Wed, 10 Oct 2007 16:10:52 -0700
On Oct 10, 2007, at 2:18 PM, Chris Heimark wrote:
On Oct 10, 2007, at 4:52 PM, John Stiles wrote:
You probably don't want to go down this route.
And is it possible to use setFileTypes to only allow the
selection of a volume?
Is the implication of this statement that there are NO fileType
symbols that would narrow the scope of the selectable files? I
presume answer is YES.
It might be possible to make it work, I just don't know off the top of
my head. Most people implement what you want via the method I described.
Yes. You will want to implement:
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename;
and return "NO" for non-volumes (you have to determine that by
whatever logic you want). This disables everything else.
You also probably want to preseed the directory to root with:
setDirectory:@"/Volumes", and/or call beginForDirectory:@"/
Volumes" -- unfortunately, /Volumes is slightly different than
the 'computer' node.
Will this technique show the boot volume (rooted at /)?
I am going to qualify the list of usable volumes for my application
using NSTask running diskutil and filtering ONLY for the volumes I
want - which in my case are USB mounted flash drives. So I may just
end up with a NSPopupButton selector filled with only qualified
volumes. So '/' will not be one of them...
So, you won't use the NSOpenPanel at all? It sounds like the
NSOpenPanel is overkill for what you want, as you want to provide the
user a very limited selection of items, and your solution may be more
ideal.
This appears to be my only alternative ... unless a future OS brings
a solution ... which I'll know about soon enough ;-)
Validating the items in the NSOpenPanel using the delegate method will
work. You could enable just the USB flash drive mounted points
(granted, I don't know how to find out what those are).
corbin
_______________________________________________
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