Search code examples
iosxcodeswiftuibuttonibaction

Connecting buttons in main storyboard to @IBAction func operate() in ViewController


I'm new to Swift and is trying out the beginner's project of building a calculator. The image below shows what stage I am up to.

However, I have just noticed that every single one of my operator buttons (except ÷) are not connected to the @IBAction func operate(sender: UIButton){}. How to connect those buttons to the @IBAction func operate(sender: UIButton){}?

enter image description here


Solution

  • You can check what outlets your buttons are connected to by right clicking on them. To connect a button to an action, hold down control while clicking and dragging from the button to the action you want to attach it to.