Xamarin.iOS – Switching from Xib Action to Xib Outlet

In this lesson

  • Replace Xib Action with Xib Outlet
  • Add event handler for button tap

Transcript

Tap on time to skip ahead

00:10

Another alternative way to accomplish the same thing, is I can go back to our Xib and I can go back to our code assistant, I go back to our header file, if I delete this action, I can instead create an outlet for the button itself. Let Xamarin Studio sync. Now what I can say is, “TimerButton.TouchedUpInside +=” like so. I can basically do the same thing here.

01:12

As for which way is better than the other, I haven’t really given enough thought with traditional. Oops! Name: NSInvalidArgumentException Reason: -[TimerViewControllerTimerButtonTapped:] I think I still have our timer tapped action. Yea. If I go back into interface building, this is where things start getting a little sticky, why some people might not like using Xibs, it’s never bothered me enough. I needed to delete the timer tapped action in the implementation as well as make sure it is gone in our header.  Let’s take a look at the button itself.

01:59

This last icon here, you can see the actual outlet that it’s wired up too. You can see it still has this reference here for timer button tapped. If I click it here, it should have finally obliterated that outlet. We no longer get an error.