开发者

set action using method from another class in objective C

is it possible t开发者_如何转开发o set an action using method from another class?? Is there any example code??


action of a button for example?

programmatically will be something like:

[button addTarget:objectX action:@selector(methodImplementedInObjectX:) forControlEvents:UIControlEvent...];

this can be written anywhere, in your view controller, inside the view itself , etc as long as you have a reference to the button. ;)

EDIT

performSelector:... methods makes the receiver perform a method. So, in your case it would be:

[objectName performSelector:@selector(methodName:) withObject:nil];

because self won't perform anything right? the one who is performing something will be objectName

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜