Use void instead of IBAction as the return type of the method

I am studying the development of ObjC and iOS. All the components that I use in my applications are created programmatically (views, buttons, labels, etc.).

Here is my code

...
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.btn addTarget:self 
                  action:@selector(someAction:) 
        forControlEvents:UIControlEventTouchDown];
....


-(void)someAction
{
 logic
}

I notice that I can use void instead of IBAction as the return type of the selector. Is this the right approach? Could there be pitfalls?

+5
source share
1 answer

Usage IBActiontells Xcode that you want this method to be available as an action method in Interface Builder. This is the only effect. Otherwise, it is identical void. In fact, UINibDeclarations.hyou will find the following:

#define IBAction void

IBAction - , nib , ( ), .

+17

All Articles