iPhone:@selector语法不同 [英] iPhone: Difference in @selector syntax
本文介绍了iPhone:@selector语法不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
最有可能是一个愚蠢的问题,但是两者之间有什么区别?
Most likely a dumb question, but what's the difference between:
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Join" style:UIBarButtonItemStylePlain
target:self action:@selector(pressJoinButton)];
和
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Join" style:UIBarButtonItemStylePlain
target:self action:@selector(pressJoinButton:)];
请注意一个是pressJoinButton,另一个是pressJoinButton:
Notice how one is pressJoinButton, and the other is pressJoinButton:
推荐答案
冒号用于向要调用的方法添加参数,因此,如果pressJoinButton的参数为零,则为:
The colon is used to add arguments to the method you are calling, so if pressJoinButton had zero arguments, it would be:
pressJoinButton
如果有一个参数,则为:
If it had one argument, it would be:
pressJoinButton:
如果有2个参数,则为:
if it had 2 arguments, it would be:
pressJoinButton:withArg1:
如果有3个参数,则为:
if it had 3 arguments it would be:
pressJoinButton:withArg1:withArg2:
等
希望这会有所帮助!
这篇关于iPhone:@selector语法不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文