I’m building an application that contain many buttons (generated dynamically). All the buttons should execute the same function when pressed. My question is how to know which button has been pressed when the function is called, in order to perform the correct job.
I’m building an application that contain many buttons (generated dynamically). All the buttons should
Share
The button instance that sends an action message to your action handler will be the
senderparameter passed to the handler. Just compare this against the button instances you have stored.Alternatively, and slightly kludgy, use the
tagfield of UIView (the superclass ofUIButton) to differentiate your buttons, and check the tag ofsender.