我是 Cocoa 编程的新手,所以,忽略这可能太明显的事实。
我希望用户选择一个带有新扩展名“.red”的文件。但 NSOpenPanel 似乎并不想要同样的东西。它不会让我选择文件或文件夹。两者都不。没有任何。这是我的代码:
NSOpenPanel *openFile = [NSOpenPanel openPanel];
NSArray *allowTypes = [NSArray arrayWithObjects:@"red", @"RED", nil];
[openFile setAllowsOtherFileTypes:true];
[openFile setAllowsMultipleSelection:false];
[openFile setCanChooseDirectories:false];
[openFile setCanChooseFiles:true];
[openFile setAllowedFileTypes:allowTypes];
if ([openFile runModal] == NSOKButton) {
}
但是当我运行它时,它没有选择任何东西......帮助?
更新:
这是上面代码产生的照片:
我希望能够只选择“Untitled.red”或“RIDE Test.red”文件。
还!我在“导出的 UTI 类型”下的项目设置中有一个导出的 UTI 类型,并且在文档类型中也有它。