找不到有关xcode警告方法定义"XXX"的问题 [英] Question about xcode warning method definition 'XXX' not found
问题描述
我在这里看到了什么 1 指出我可以通过将-(IBAction)shakeShakeShake之类的方法更改为-(IBAction)shakeShakeShake(id)发送者,来消除xcode 3中的这些错误
I have seen something here1 that states that I can remove these errors in xcode 3 by changing a method like -(IBAction) shakeShakeShake to -(IBAction) shakeShakeShake (id) sender
我正在雪豹上使用iphone sdk 3.0和xcode 3.2.1
I am using iphone sdk 3.0 and xcode 3.2.1 on snow leopard
我的错误是:
Classes/MainViewController.m:156:警告:"MainViewController"可能不响应"-shakeShakeShake"
Classes/MainViewController.m:156: warning: 'MainViewController' may not respond to '-shakeShakeShake'
/Users/temp/Desktop/src/Count Down Timer(Utility App)/Classes/MainViewController.m:156:0/Users/temp/Desktop/src/Count Down Timer(Utility App)/Classes/MainViewController. m:156:警告:(没有匹配方法签名的邮件
/Users/temp/Desktop/src/Count Down Timer (Utility App)/Classes/MainViewController.m:156:0 /Users/temp/Desktop/src/Count Down Timer (Utility App)/Classes/MainViewController.m:156: warning: (Messages without a matching method signature
Classes/MainViewController.m:在顶层:
Classes/MainViewController.m: At top level:
Classes/MainViewController.m:467:警告:类'MainViewController'的实现不完整
Classes/MainViewController.m:467: warning: incomplete implementation of class 'MainViewController'
Classes/MainViewController.m:467:警告:-pickerView:"的方法定义未找到
Classes/MainViewController.m:467: warning: method definition for '-pickerView:' not found
Classes/MainViewController.m:467:警告:-shakeShakeShake:"的方法定义未找到
Classes/MainViewController.m:467: warning: method definition for '-shakeShakeShake:' not found
-----(很抱歉,错误消息很长,我试图通过删除编译器和路径信息来减少它们)---
----- (sorry about the long error msgs, I tried to cut them down by removing compiler and path info) ---
我尝试添加类似的东西
-(void)shakeShakeShake: (id) sender ;
作为.h文件和.m文件的原型
as a prototype to the .h file and to the .m file
- (IBAction) shakeShakeShake: (id) sender {
dimView.alpha = 0.0f; }
dimView.alpha = 0.0f ; }
进行这些更改将使警告消失,但是当我运行程序并执行此功能时,它将通过控制台消息退出跳板:
Making these changes will make the warning go away, but when I run my program and execute this function, it will exit to the Springboard with a console message:
[MainViewController shakeShakeShake]:无法识别的选择器已发送到实例0x1213a20 2009-12-21 02:19:17.389倒数计时器(实用程序应用程序)[43704:207] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'* -[MainViewController shakeShakeShake]:无法识别的选择器已发送到实例0x1213a20'
[MainViewController shakeShakeShake]: unrecognized selector sent to instance 0x1213a20 2009-12-21 02:19:17.389 Count Down Timer (Utility App)[43704:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[MainViewController shakeShakeShake]: unrecognized selector sent to instance 0x1213a20'
当我将函数改回-(IBAction)shakeShakeShake { (即使我将原型样式保留为:(id)sender),该程序(一个简单的实用程序计时器)也可以正常运行,并且不会对控制台造成任何错误.
When I change the function back to - (IBAction) shakeShakeShake { (even if I leave the prototype style in with : (id) sender), the program (a simple utility timer) runs fine and gives no errors to the console.
我似乎无法弄清楚我在做什么错,但是我总是被教导要尽可能删除警告,因为警告可能会指出一些问题,这些问题只会在以后浮出水面,并且很难发现.
I can't seem to figure out what I'm doing wrong, but I was always taught to remove warnings if possible as they may note problems that only surface later and are hard to find.
有人可以在这里向我指出正确的方向吗?非常感谢您的耐心等待,我仍然很陌生! ;-)
Can anyone point me in the right direction here? thanks very much for your patience, I'm still new at this! ;-)
感谢虔诚
顺便说一句,shakeShakeShake在这里被称为:
BTW, shakeShakeShake is called here:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if(event.type == UIEventSubtypeMotionShake){ //您的代码在这里 [self shakeShakeShake]; } }
if (event.type == UIEventSubtypeMotionShake) { //Your code here [ self shakeShakeShake ] ; } }
----错误消息遵循
---- error msgs follow
Classes/FlipsideViewController.m:401:警告:类'FlipsideViewController'的实现不完整 类/FlipsideViewController.m:401:警告:未找到"-pickerView:"的方法定义 类/FlipsideViewController.m:401:警告:未找到"-shakeShakeShake"的方法定义
Classes/FlipsideViewController.m:401: warning: incomplete implementation of class 'FlipsideViewController' Classes/FlipsideViewController.m:401: warning: method definition for '-pickerView:' not found Classes/FlipsideViewController.m:401: warning: method definition for '-shakeShakeShake' not found
推荐答案
看来我需要在消息调用中明确给sender参数,如下所示:
It looks like I need to give the sender parameter explicitly as follows in the message call:
//instance method declaration
- (IBAction) shakeShakeShake: (id) sender ;
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
// message -- method signature + parameter information
[ self shakeShakeShake: self ] ;
}
}
// ^-- needed for shake
//instance method definition
- (IBAction) shakeShakeShake: (id) sender {
// make window clear
dimView.alpha = 0.0f ; // always undim screen in shake as a failsafe
}
当我这样做时,警告消失并且该应用似乎正常运行.谢谢你的时间.虔诚主义
When I do it like this, the warnings go away and the app seems to work. Thanks for your time. Piesia
这篇关于找不到有关xcode警告方法定义"XXX"的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!