本文介绍了使用Xcode 4.5.1进行调试时,NSOpenPanel崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于文档的应用程序.自从4.4升级到XCode 4.5.1(从4.4开始)以来,NSOpenPanel在我从Xcode调试应用程序时崩溃.直接启动程序时它不会崩溃.

I have a document-based application. Since upgrading to XCode 4.5.1 (from 4.4) NSOpenPanel crashes when I debug the application from Xcode. It does not crash when I start the program directly.

我有两种情况使用NSOpenPanel:当用户从文件"菜单中选择打开"时(由于它是基于文档的应用程序,因此不涉及我自己的代码),并且将一些数据导入到我的文档中(因此它由我自己的代码调用). NSOpenPanel两次都崩溃(对话框打开,但是在我做任何事情之前,都会引发异常).

I use NSOpenPanel on two occasions: When the user selects "Open" from the "File" menu (since it is a document-based application, none of my own code is involved) and for importing some data into my document (so it gets called by my own code). NSOpenPanel crashes on both occasions (the dialog opens, but before I can do anything, an exception is raised).

我做了干净的尝试,尝试将编译器从Apple LLVM切换到LLVM GCC,将调试器从LLDB切换到GDB,然后再返回,但是没有任何更改.

I made clean, tried switching compiler from Apple LLVM to LLVM GCC and debugger from LLDB to GDB and back, but no change.

这是我的导入代码:

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];

在CodeSigning检查期间似乎崩溃了(我的应用程序未进行代码签名):

It seems to crash somewhere during CodeSigning checks (my application isn't code signed):

我必须建立一个新项目吗?任何帮助表示赞赏...

Do I have to set up a new project? Any help is appreciated...

非常感谢.

推荐答案

我找到了原因:我在所有异常"上设置了一个断点.当我禁用它或选择评估后自动继续"时,它将起作用.我想这与App Sandbox有关.

I found the reason: I had a breakpoint set on "All Exceptions". When I disable it or select "Automatically continue after evaluating" it works. I guess it is related to App Sandbox.

这篇关于使用Xcode 4.5.1进行调试时,NSOpenPanel崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 15:08