Q: Passing uibutton tag through UILongPressGestureRecognizer? I am trying to use the long press button function but am not sure how to pass the tag of the button to the function. I have an array of buttons called ChannelButton. The long button press works with the code below. 
for button in ChannelButton {
        let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(sender:)))
        button.addGestureRecognizer(longPressGestureRecognizer)
    }
func handleLongPress(sender: UILongPressGestureRecognizer) {
        doSomeFunction(NeedToPassTheButtonsTagHere)
}

But I need it to modify it to be something like this
for button in ChannelButton {
        let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(sender:, button.tag)))
        button.addGestureRecognizer(longPressGestureRecognizer)
    }


    func handleLongPress(sender: UILongPressGestureRecognizer, buttontag) {
        doSomeFunction(buttontag)
}

I know this doesn't work but I'm not sure how to go about it.

A: A UIGestureRecognizer has a view property that is the view that it is attached to.  In your case, it will be your button.  Use it to get to your button's tag:
func handleLongPress(sender: UILongPressGestureRecognizer) {
    guard let button = sender.view as? UIButton else { return }

    doSomeFunction(button.tag)
}


A: You're trying to add an EXTRA parameter (an int) to an IBAction selector. You can't do that. IBActions have one of 3 selectors:
@IBAction func actionNoParams() {
}

@IBAction func actionWSender(_ sender: Any) {
}

@IBAction func actionWSenderAndEvent(_ sender: Any, forEvent event: UIEvent) {
}

One solution would be to look for the location of your long press gesture, and then check what button has that location.
func handleLongPress(sender: UILongPressGestureRecognizer) {

    if sender.state == UIGestureRecognizerState.began {

        let location = sender.location(in: self.view)

        for button in ChannelButton {

            if button.frame.contains(location) {

                //This is the button that is pressed
                //Do stuff
            }
        }
    }
}

Remember to conform to UIGestureRecognizerDelegate
