I’ve these capabilities:
non-public func chooseOfferButton1Tapped() {
let vc = ChooseRdvVC()
vc.offerCatched = arrayCatched![0]
HapticsManager.shared.vibrate(for: .success)
navigationController?.pushViewController(vc, animated: true)
}
non-public func chooseOfferButton2Tapped() {
let vc = ChooseRdvVC()
vc.offerCatched = arrayCatched![1]
HapticsManager.shared.vibrate(for: .success)
navigationController?.pushViewController(vc, animated: true)
}
...
as much as:
...
non-public func chooseOfferButton50Tapped() {
let vc = ChooseRdvVC()
vc.offerCatched = arrayCatched![49]
HapticsManager.shared.vibrate(for: .success)
navigationController?.pushViewController(vc, animated: true)
}
Here is how I name the capabilities:
let index = "chooseOfferButton(oneViewSize)Tapped"
chooseOfferButton.addTarget(self,
motion: Selector(index),
for: .touchUpInside)
the place oneViewSize
is the quantity that modifications
I am in search of a technique to keep away from penning this identical perform again and again solely with 2 numbers altering. How can I exploit a string in a perform identify? Or a for loop? Or is there one other method? Any assistance is appreciated.