I have a -(void)assignCats
method in my test project, and I need to trigger the code in it from two seperate buttons. I know how to use IBAction, but how do I make two IBActions trigger the same (void)?
Just call your method from within the IBAction
methods.
-(IBAction)pointAtCats:(id)sender {
[self assignCats];
}
-(IBAction)laughAtCats:(id)sender {
[self assignCats];
}
IBAction
is also actually a void
return typedef
. It is simply used by Xcode to know what is available for use in interface connections.
Just hook them both up to the same action. IBAction
is just defined to be void
, so you could just change the assignCats
signature without changing any other program behaviour. Alternately, write a new action that calls assignCats
from its implementation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.