找不到 Xcode 实例方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9160925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:14:00  来源:igfitidea点击:

Xcode Instance method not found

objective-cxcodeinstance

提问by user1175380

sometimes I get the Warning for example :

有时我会收到警告,例如:

Instance method '-PushBottom' not found (return type defaults to 'id')

未找到实例方法“-PushBottom”(返回类型默认为“id”)

because the function PushBottom is under this function (where it called) declared.

因为函数 PushBottom 是在这个函数(它调用的地方)下声明的。

For fixing this warning I put the function PushBottom about this function (where it called).

为了修复这个警告,我把函数 PushBottom 放在这个函数(它调用的地方)。

Is there any way to get fix this warning without put function PushBottom about the function where it called?

有没有办法在不将函数 PushBottom 关于它调用的函数的情况下修复这个警告?

回答by glogic

you could declare the push button in the .h file

您可以在 .h 文件中声明按钮

-(void)PushButton;

or -(IBAction)PushButton:(id)sender;

或者 -(IBAction)PushButton:(id)sender;

depending on what the function is. just declare it in the .h file above the @end and u should be good to go

取决于功能是什么。只需在@end 上方的 .h 文件中声明它,您就可以开始使用了

回答by Gaz_Edge

I would define it in your .m file (the .h file is your public api file and unless you want it to be public, I wouldnt put it in there as suggested in another answer).

我会在您的 .m 文件中定义它(.h 文件是您的公共 api 文件,除非您希望它是公开的,否则我不会按照另一个答案中的建议将它放在那里)。

Above the @implementationIn your .m file write:

@implementation在您的 .m 文件上方写入:

@interface yourClassName()
-(void)yourMethod;

@end