Reputation: 185
I am having trouble configuring a button that:
...and so on
Is there any way to configure that button?
Thanks
Upvotes: 2
Views: 123
Reputation: 186
If you were interested in keeping track of the number of clicks while also doing the job of the 3 alternating tasks:
var counter : Int = 0
@IBAction func buttonClicked(_ sender: Any) {
counter+=1
//print(counter)
switch counter % 3 {
case 1:
// First Action
case 2:
// Second Action
default:
// Third Action
}
}
Upvotes: 2
Reputation: 625
Do as below in your button action:
var counter = 0
@IBAction func buttonTapped(_ sender: Any) {
counter += 1
switch counter {
case 1:
// do your action
case 2:
// do your action
case 3:
// do your action
counter = 0
default:
break
}
}
Upvotes: 1