iOS指南系列:如何解决奔溃问题-关于内存访问续
来源:互联网 发布:和大胸妹子嘿嘿知乎 编辑:程序博客网 时间:2024/06/05 05:16
Push the Button
现在的应用程序工程 - 或者至少是没有问题的开始 - ,点击该按钮运行。
Woah! 程序又崩溃了 SIGABRT ,还在 main.m.
在调试窗格中的错误消息是:
Problems[6579:f803] -[MainViewController buttonTapped]: unrecognized selector sentto instance 0x6e44850
堆栈跟踪不是太清晰,它列出了一大堆有关单程或其他发送事件和执行行动的方法,但你已经知道,行动参与。毕竟,你可以找到一个被称为IBAction方法的UIButton和结果。可以看到NSobject Performaselector执行了一个方法:
当然,你见过这个错误讯息。”一种方法被称为不存在的“。这一次的目标对象是MainViewController,看起来是正确的操作方法之一,因为通常包含按钮在视图控制器。如果你在MainViewController.h看,IBAction方法也确实是存在的:
- (IBAction)buttonTapped:(id)sender;
我们可以和之前的步骤一样,继续点击执行,直到错误被完全抛出:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainViewController buttonTapped]: unrecognized selector sent to instance 0x6b4b1f0'
这次看到多一个信息,参数不合法!- (IBAction)buttonTapped;
你可以看到的storyboard,按钮连接inspector(MainviewController-buttontapped):
首先断开触摸内部事件(点击小X),然后将它连接主视图控制器,但这个时候选择的buttonTapped的方法是现有的。链接后,请注意,在连接inspector,现在 方法的名称后有个小冒号(表明是带参数的)。
运行的应用程序,再点击按钮。什么?在main函数中,你又得到“无法识别的selector”的消息,虽然这一次正确识别作为buttonTapped:的 方法
Problems[6675:f803] -[MainViewController buttonTapped:]: unrecognized selector sentto instance 0x6b6c7f0
If you look closely, the compiler warnings should point you to the solution again. Xcode complains that the implementation of MainViewController is incomplete. Specifically, the method definition for buttonTapped:is not found.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainViewControllerbuttonTapped:]: unrecognizedselector sent to instance 0x6d37a00'
轮到检查 MainViewController.m. 看起来似乎有定义(我也没有发现这个拼写错误) buttonTapped: 但是等一下… 好像不对头啊:
- (void)butonTapped:(id)sender
很容易解决,修改下:
- (void)buttonTapped:(id)sender
注意,这里就没有必要申明为IBAction, 如果你愿意,当然也可以!
Note: This sort of thing is easy to catch if you’re paying attention to the compiler warnings. Personally, I treat all warnings as fatal errors (there is even an option for this in the Build Settings screen in Xcode) and I’ll fix each and every one of them before running the app. Xcode is pretty good at pointing out silly mistakes such as these, and it’s wise to pay attention to these hints.
- iOS指南系列:如何解决奔溃问题-关于内存访问续
- iOS指南系列:如何解决奔溃问题-关于内存访问续
- iOS指南系列:如何解决奔溃问题-关于内存访问续
- iOS指南系列:如何解决奔溃问题-关于内存访问续2
- iOS指南系列:如何解决奔溃问题-关于内存访问
- iOS指南系列:如何解决奔溃问题-关于内存访问
- iOS指南系列:如何解决奔溃问题
- iOS指南系列:如何解决奔溃问题-深入调试
- iOS指南系列:如何解决奔溃问题-深入调试
- iOS指南系列:如何解决奔溃问题
- iOS指南系列:如何解决奔溃问题 .
- iOS指南系列:如何解决奔溃问题-深入调试
- iOS指南系列:如何解决奔溃问题
- iOS指南系列:如何解决奔溃问题
- iOS指南系列:如何解决内存问题 深入调试 结尾篇
- iOS指南系列:关于进度条的问题
- iOS 指南系列: 内存管理
- 如何解决iOS内存错误
- 取消可执行文件加载时重新定位的方法----方便window7下调试
- Centos下安装glibc静态库
- android 保证屏幕黑屏之后线程可以继续运行
- QtXml帮助文档翻译
- 解决“krb5.h: No such file or directory” 问题
- iOS指南系列:如何解决奔溃问题-关于内存访问续
- div自动适应浏览器窗口水平和垂直居中
- 怎样的数据中心才算符合“云计算”的特征?
- rpm命令参数列表
- Android的单位及屏幕分辨率
- android linux kernel 下载
- 第18题: 题目:n个数字(0,1,„,n-1)形成一个圆圈,从数字0开始, 每次从这个圆圈中删除第m个数字(第一个为当前数字本身,第二个为当前数字的下一个数字)。 当一个数字删除后,从被删除数字的下
- IE下checkbox无法立即响应onchange的解决方法
- 表单验证js插件