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

View Hierarchy Recursion

Just a couple notes here, nothing earth shattering. If you have a custom UITableViewCell with controls of some sort and you want to know in which cell a the value of a control changed, there are a few ways, one of which is bad, one of... Continue →