Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the arguments 'sender' and 'none' for an IBAction in iOS

While creating a new IBAction Method, I have dragged from the Button in the storyboard to my header file as I should. The Popup that appears I have noticed has an arguments dropdown which offers 3 options which are none, sender and sender and event. What is the difference between 'none' and 'sender' and in what situations would each be used?

like image 980
Destin M Avatar asked Oct 16 '25 17:10

Destin M


1 Answers

None
You don't need to know any information about what triggered the action, just that the action was triggered.

Sender
You not only need to know that an action was triggered, but information about what object triggered the action. For instance, if you need to know which button triggered a certain action in order to change its properties.

Sender and event
You need to know the action was triggered, what object triggered this action, and the type of event that triggered the action. For example, if you need to know which button triggered a certain action in order to change its properties, and you will change them differently if they touch down on the button vs touch up vs double-tap vs etc. but you don't want to create a separate action method for each type of event.

like image 73
Stonz2 Avatar answered Oct 18 '25 06:10

Stonz2