连接了一个没有代码的计算器按钮,将其删除,现在模拟器崩溃了

发布于 2024-11-27 15:48:51 字数 274 浏览 2 评论 0原文

我对 xcode 相当陌生,所以如果这个问题很微不足道,我深表歉意。我正在关注itunesU上的CS193P讲座,如果这有助于提前了解的话。

我创建了计算器,一切运行良好。然后,我将 xib 文件中的 sqrt 按钮连接到按下的 IBAction 操作。但是,我的 CalculatorBrain.m 文件中没有实现代码。我运行了该程序,它工作得很好,直到我执行了一个操作(*、+等),所以我删除了 sqrt 操作,认为这将是错误的根源,但它仍然崩溃。

知道我需要做什么才能使程序恢复到工作状态吗?谢谢

I'm fairly new to xcode so I apologize if this question is trivial. I'm following the lectures on itunesU for CS193P if that helps to know beforehand.

I created the calculator and everything was running fine. I then wired up a sqrt button in the xib file to my IBAction operation pressed. However, I did not have the code implemented in it in my CalculatorBrain.m file. I ran the program, and it worked just fine until I hit an operation (*,+,etc) so I deleted the sqrt operation thinking that would be the source of the error but it still crashes.

Any idea what I need to do in order to return the program to a working state? Thanks

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

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

发布评论

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

评论(2

紫罗兰の梦幻 2024-12-04 15:48:51

当您删除对象(即按钮)时,您必须删除 Interface Builder 中的引用。

you have to remove your reference in Interface Builder when you delete an object (i.e. the button).

青瓷清茶倾城歌 2024-12-04 15:48:51

我不确定如果从 .m 文件中删除按钮操作的实现,是否会崩溃。但如果您想从 .h 文件中删除,那么您应该删除 sqrt 按钮的操作。
打开 xib 文件,您可以看到警告(带有*符号的黄色突出显示颜色)只需单击该问题即可解决

I am not sure if you remove the implementation of button action from .m file, will crash. but if you would have deleted from .h file then you should removed the action of your sqrt button.
Open the xib file and there you can see the warning(with yellow highlighted color with * symbol) just click on that problem solved

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