本文介绍了呼叫“(id)发件人"; Xcode中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我想调用的方法:
- (void)myMethod:(id)sender {
我怎么称呼它?我试过了:
How would I call it? I tried:
[self myMethod]
^ 错误:]"标记之前的预期表达式.
我知道这是一个简单的问题,但是我是iPhone开发的新手
I know this is a simple question, but I am new to iPhone Development
推荐答案
该方法采用一个参数,因此您必须给它一个参数.如果您没有想要发送的发件人,只需输入nil:
The method takes one parameter, so you have to give it one. If you have no sender you want to give, just pass nil:
[self myMethod:nil];
为方便起见,您也可以重载该方法:
You could also overload the method as a convenience:
// declarations
- (void)myMethod;
- (void)myMethod:(id)sender;
// implementations
- (void)myMethod { [self myMethod:nil]; }
- (void)myMethod:(id)sender { /* do things */ }
这篇关于呼叫“(id)发件人"; Xcode中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!