An action is a piece of code that’s linked to some kind of event that can occur in your app. When that event takes place, the code gets executed. You can define an action to accomplish anything from manipulating a piece of data to updating the user interface. You use actions to drive the flow of your app in response to user or system events.
You define an action by creating and implementing a method with an
IBAction
return type and a sender
parameter.- (IBAction)restoreDefaults:(id)sender;
The
sender
parameter points to the object that was responsible for triggering the action. The IBAction
return type is a special keyword; it’s like the void
keyword, but it indicates that the method is an action that you can connect to from your storyboard in Interface Builder (which is why the keyword has the IB
prefix).