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
精彩评论