简单项目 XCode 4 上的 EXC_BAD_ACCESS

发布于 2024-11-03 14:32:56 字数 249 浏览 2 评论 0原文

我需要 Xcode 4 的帮助。我开始了一些非常简单的事情,创建了一个 cocoa 项目并添加了一个 Window 对象并将其称为首选项。 然后,为了访问这个新窗口,我将其与菜单项“Preferences”操作 makeKeyAndOrderFront 链接。 就是这样,当我运行应用程序时,第一次单击“首选项”菜单项时,首选项窗口打开得很好...在我关闭它并再次单击首选项菜单项后,应用程序崩溃并显示 EXC_BAD_ACCESS main.m

有谁知道问题是什么?

I need help with Xcode 4. I started something very simple, created a cocoa project and added a Window object and called it preferences.
Then in order to access this new window I linked it with the menu item "Preferences" action makeKeyAndOrderFront.
Just that, then when I run the application, the first time I click on the Preferences menu item, the preferences window open just fine ... after I close it and click again on the preferences menu item, then application crashes with EXC_BAD_ACCESS on the main.m

Does anyone knows what is the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新一帅帅 2024-11-10 14:32:56

我遇到了完全相同的问题,我怀疑我们都遵循相同的稀疏教程信息来制作像苹果那样的首选项窗口。

我刚才通过设置 window = nil 解决了这个问题,而不是尝试使用 [window autorelease]。正如我测试的那样,使用 [window release] 会立即导致问题,而 [window autorelease] 会导致第二次崩溃。

I had exactly the same problem, and I suspect we were both following the same trail of sparse tutorial information out there to make a Preferences window like Apple's.

I solved this issue just now by just setting window = nil, and not trying to get fancy with [window autorelease]. As I tested, using [window release] would cause the issue instantly, while [window autorelease] would create that second-time crash.

放肆 2024-11-10 14:32:56

我有同样的行为。经过一些测试后,我了解到问题在于,第二次单击首选项菜单时,您向已释放的窗口发送一条消息(该对象不再存在)。您可以通过在 XCode 可执行文件的“参数”选项卡上添加设置为“YES”的“NSZombieEnabled”环境变量来验证它。

我解决了这个问题,在用作首选项窗口的窗口的界面生成器中取消选择“关闭时释放”检查。

再见。彼得.

I Had the same behaviour. After some tests I understood that the problem is that the second time you click the preferences menu you send a message to the window that has been released (the object does not exist anymore). You can verify it by adding the 'NSZombieEnabled' environment variable set to 'YES' on the 'Arguments' Tab of your executables from XCode.

I solved this issue deselecting the 'release when closed' check in the interface builder for the window used as the preferences window.

Bye. Peter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文