I have these functions:
private func chooseOfferButton1Tapped() {
        let vc = ChooseRdvVC()
        vc.offerCatched = arrayCatched![0]
        HapticsManager.shared.vibrate(for: .success)
        navigationController?.pushViewController(vc, animated: true)
    }
    
    private func chooseOfferButton2Tapped() {
        let vc = ChooseRdvVC()
        vc.offerCatched = arrayCatched![1]
        HapticsManager.shared.vibrate(for: .success)
        navigationController?.pushViewController(vc, animated: true)
    }
                   ...
up to:
                   ...
private func chooseOfferButton50Tapped() {
        let vc = ChooseRdvVC()
        vc.offerCatched = arrayCatched![49]
        HapticsManager.shared.vibrate(for: .success)
        navigationController?.pushViewController(vc, animated: true)
    }
Here's how I call the functions:
let index = "chooseOfferButton\(oneViewSize)Tapped"
chooseOfferButton.addTarget(self,
                            action: Selector(index),
                            for: .touchUpInside)
where oneViewSize is the number that changes
I'm looking for a way to avoid writing this same function over and over only with 2 numbers changing. How can I use a string in a function name? Or a for loop? Or is there another way? Any help is appreciated.
 
     
    