Re: Can't open specified type in NSOpenPanel
Re: Can't open specified type in NSOpenPanel
- Subject: Re: Can't open specified type in NSOpenPanel
- From: Timothy Carl Buchheim <email@hidden>
- Date: Mon, 23 Feb 2004 12:01:15 -0800
On Feb 23, 2004, at 9:01 AM, Randall Meadows wrote:
Given the snippet of code:
NSOpenPanel *panel = [NSOpenPanel openPanel];
if (panel) {
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:NO];
[panel setDelegate:self];
[panel beginSheetForDirectory:nil file:nil types:[NSArray
arrayWithObjects:@"asdf", nil] modalForWindow:setupWdw
modalDelegate:self
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
why are my files with an HFS type of "asdf" (no extension) NOT
selectable in an Open panel?
You need to use NSFileTypeForHFSTypeCode(OSType hfsTypeCode) to encode
the HFS file type in a special format which tells NSOpenPanel to treat
it as an HFS file type. (Otherwise it thinks you're specifying an
extension ... your code is telling it to look for files with a ".asdf"
extension.)
The following documentation shows how to do this:
http://developer.apple.com/documentation/Cocoa/Conceptual/
LowLevelFileMgmt/Concepts/HFSFileTypes.html
By the way, this question has previously been asked and answered
several times on this list. You can use the list archives at
http://cocoa.mamasam.com/ to see whether a question has already been
answered.
--
Tim Buchheim System Administrator
Computer Science Department Phone: (909) 607-3485
Harvey Mudd College Fax: (909) 607-8364
1250 N Dartmouth Ave E-mail: email@hidden
Claremont, CA 91711
http://www.cs.hmc.edu/~tcb/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.