---
title: "iOS : IBAction of UI element"  
description: "Previously we learn about IBOutlet elementiOS : IBOutlet of UI element  As early as 2004 (and perhaps earlier), IBAction was no longer necessary for a"  
author: "Anonymous User"  
published: 2015-07-20  
updated: 2018-02-27  
canonical: https://www.mindstick.com/blog/10932/ios-ibaction-of-ui-element  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# iOS : IBAction of UI element

Previously we learn about IBOutlet element: [iOS : IBOutlet of UI element](https://www.mindstick.com/Blog/10931/iOS%20IBOutlet%20of%20UI%20element)\

**As early as 2004 (and perhaps earlier)**, IBAction was no longer necessary for a method to be noticed by [Interface](https://www.mindstick.com/articles/12101/interfaces-in-java-extending-interfaces) Builder. Any method with the signature -(void){name}:(id)sender would be visible in the outlets' pane.

Nevertheless, many [developers](https://www.mindstick.com/blog/302688/handling-errors-in-rust-a-comprehensive-guide-for-developers) find it useful to still use the IBAction return type in method declarations to denote that a particular method is [connected](https://www.mindstick.com/articles/12941/link-building-and-search-engine-rankings-how-are-they-connected) to by an action. **Even projects not using Storyboards** / XIBs may choose to employ IBAction to call out target/action methods.

IBActions are methods that are called when some [action is taken](https://answers.mindstick.com/qa/38028/a-money-bill-passed-by-the-lok-sabha-is-deemed-to-have-been-passed-by-the-rajya-sabha-also-when-no-action-is-taken-by-the-rajya-sabha-within-how-many-days) - for example, when a button is pressed, it should call a method in [your code](https://www.mindstick.com/forum/157976/how-can-you-use-jquery-s-testing-framework-such-as-qunit-to-write-unit-tests-for-your-code). These methods are declared in your class's @interface (.h) file.

**Naming IBAction Methods**

Thanks to strong, and often compiler-enforced conventions, naming is especially important in Objective-C, so the question of how to name IBAction methods is one not taken lightly. Though there is some disagreement, **the preferred [convention](https://www.mindstick.com/forum/145551/what-is-naming-convention-and-its-types) is as follows**:

- **Return type of IBAction**.
- **[Method name](https://www.mindstick.com/forum/33583/selector-creation-with-method-name-and-parameter) of an active verb, describing the specific action performed.** [Method names](https://www.mindstick.com/forum/157800/what-happens-in-case-of-the-inherited-interfaces-have-conflicting-method-names) like didTapButton: or didPerformAction: sound more like things a delegate might be sent.
- **Required sender parameter of type id**. All target/action methods will pass the sender of the action (usually the responder) to methods that take a parameter. If omitted in the method signature, things will still work.
- **Optional event parameter of type UIEvent *, named withEvent**: (iOS only). In UIKit, a second UIEvent * parameter, corresponding to the touch, motion, or [remote control](https://answers.mindstick.com/qa/108708/what-are-quick-solutions-for-a-tv-with-a-remote-control-delay) event triggering the responder, will be passed to target/action methods accepting this second parameter. The convention is to use withEvent: in the method signature, to match the UIResponder APIs.

For example:

```
// YES- (IBAction)refresh:(id)sender; - (IBAction)toggleVisibility:(id)sender                   withEvent:(UIEvent *)event; // NO- (IBAction)peformSomeAction; - (IBAction)didTapButton:(id)sender;
```

---

Original Source: https://www.mindstick.com/blog/10932/ios-ibaction-of-ui-element

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
