1

I am wondering how do we make an action connection for multiple buttons in Xcode10. Just ONE CODE for ALL buttons.NOT SEPARATE.

For example, we have 7 music key buttons, and we want to make one action connection for all 7 of them, and then continue to code to make the code know which key is being exactly pressed. As the code that I posted in this question, how do we make " @IBAction func notePressed(_ sender: UIButton)" this line? Not by typing, by clicking and dragging.

Another example is, we have "true" and "false", two buttons. We want to make just one action connection for these two buttons in ViewController.swift.

I know how to make one action connection for a single button, but when it comes to multiple buttons, I do not know how to do. I use xcode10

I have tried to hold the command and select all the buttons at the same time, and then hold the control key and try to drag all the buttons from the mainStoryBoard to my swift code, but it seems that I only created an action connection for on button in this way.

@IBAction func notePressed(_ sender: UIButton)
    {
        let selectedNote : String = soundArray[sender.tag - 1]
        playSound(inputNote : selectedNote)

    }

1 Answer 1

0

If you find the connected actions part in the First Responder part in the storyboard, you are able to connect it one by one as the screenshot.

ios storyboard

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.