Question: Swift: Modify DoIncrease and DoDecrease functions so that the counter is limited in 0 and 20 (including 0 and 20). I do not need running
Swift:
Modify DoIncrease and DoDecrease functions so that the counter is limited in 0 and 20 (including 0 and 20).

I do not need running code.
9 import UIkit 10 11 class ViewController: UIViewController { 12 13 var counter: Int? 14 15 16 O O CIBOutlet weak var plus: UIButton! @IBOutlet weak var minus: UIButton! CIBOutlet weak var cntLabel: UILabel! 20 21 CIBAction func DoIncrease sender: Any) { 23 24 counter = counter! + 1 cntLabel.text = String(counter!) 25 26 27 28 } 29 30 O 32 33 34 CIBAction func DoDecrease ( _ sender: Any) { counter = counter! - 1 cntLabel.text = String(counter!) } override func viewDidLoad() { super.viewDidLoad() counter = 0 35 36 37 38 } 39 40 41 42 } 43
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
