Better IBActions

This is a small thing, but I am not sure how I have never seen anyone describe this feature of creating IBActions with storyboards, and quick googling doesn’t show me anything obvious.

But when you ctrl-click-drag from UIButton (UIControl) into the implementation section of code in a .m, you get a popup for naming the IBAction that looks like this:


<yawn> Yes, we all know that. But as you can see there are options that can be used, and sometimes we should!

 Instead of using the standard event TouchUpInside:

ibButton - events.png

 Nor does the sender need to be typed to the default (id)sender:

ibButton 1.png

 Lastly, you can choose which arguments are sent to the method:

ibButton choose arguments.png

Being able to choose the type of event right there in the pop-up is great, I was previously, using the side “Attributes Inspector” to drag and connect things. Not as simple.

Being able to have the argument as a typed argument is a nice thing, rather than doing it by hand or not doing at all, thus depriving the compiler to help along with method completions.

And I was simply unaware that I could send the event as an argument to the method, and that is something that I am sure will be very helpful.


Now read this

Dipping Toe Further into Swift – Generics Edition

Work developments have prevented me from doing a lot of iOs, so as things are heating up with Swift and functional programming, my main involvement is reading. But I was reading this post by Andrew Bancroft on using Swift functions to... Continue →