且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Objective-C中调用方法?

更新时间:2022-11-24 15:41:13

要在这种情况下发送Objective-C消息,您可以这样做

[self score];

我建议您阅读Objective-C编程指南 《 Objective-C编程指南》 >

I am trying to build an iPhone app. I created a
method like this:

- (void)score {
    // some code
}

and I have tried to call it in an other method like this:

- (void)score2 {
    @selector(score);
}

But it does not work. So, how do I call a method correctly?

To send an objective-c message in this instance you would do

[self score];

I suggest you read the Objective-C programming guide Objective-C Programming Guide