Check out example codes for "array of button listeners swift". It will help you in understanding the concepts better.

Code Example 1

class ViewController: UIViewController {
    @IBOutlet weak var verticalStackView: UIStackView!

    var allButtons = [UIButton]()

    override func viewDidLoad() {

        for case let horizontalStackView as UIStackView in verticalStackView.arrangedSubviews {
            for case let button as UIButton in horizontalStackView.arrangedSubviews {

Learn ReactJs, React Native from