开发者

set action using method from another class in objective C

开发者 https://www.devze.com 2023-01-31 12:30 出处:网络
is it possible t开发者_如何转开发o set an action using method from another class?? Is there any example code??action of a button for example?

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

精彩评论

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