我有一个基于文档的应用程序.自从升级到XCode 4.5.1(从4.4)以来,当我从Xcode调试应用程序时,NSOpenPanel崩溃了.直接启动程序时它不会崩溃.
我在两种情况下使用NSOpenPanel:当用户从"文件"菜单中选择"打开"时(因为它是基于文档的应用程序,不涉及我自己的代码)以及将一些数据导入我的文档(因此它得到了我自己的代码调用).NSOpenPanel在两种情况下崩溃(对话框打开,但在我可以做任何事情之前,会引发异常).
我做了干净,尝试将编译器从Apple LLVM切换到LLVM GCC,并将调试器从LLDB切换到GDB并返回,但没有变化.
这是我的导入代码:
long result;
NSArray *fileTypes = [NSArray arrayWithObjects: @"txt", @"csv", @"text",
NSFileTypeForHFSTypeCode( 'TEXT' ), nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setAllowsMultipleSelection:NO];
[oPanel setAllowedFileTypes:fileTypes];
[oPanel setMessage:@"Please select import file:"];
result = [oPanel runModal];
Run Code Online (Sandbox Code Playgroud)
它似乎在CodeSigning检查期间崩溃(我的应用程序没有代码签名):

我是否必须建立一个新项目?任何帮助表示赞赏......
非常感谢.
当我创建一个NSOpenPanel时,像这样:
int i;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:YES];
if ([openDlg runModalForDirectory:nil file:nil] == NSOKButton)
{
NSArray* files = [openDlg filenames];
for( i = 0; i < [files count]; i++ )
{
NSString* fileName = [files objectAtIndex:i];
NSLog(fileName);
NSString *catched = fileName;
[self performSelector:@selector(decompresss2z:) withObject:catched];
}
}
Run Code Online (Sandbox Code Playgroud)
当我记录fileName,它是正确的并打印我的文件完整目录,但当我尝试使用它与我的虚空,它就像超级奇怪的字母,像ÿ^ 0f完全随机.为什么?