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:

initialView

<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.

 
0
Kudos
 
0
Kudos

Now read this

Swift: map vs. flatMap For Dummies

tl;dr Summary # This is me, figuring out how map and flatMap work in Swift. tl;dr Conclusions: # Think of optionals as an array that can hold 1 or 0 items. Arrays and optionals are both containers that can have map or flatMap applied map... Continue →