Search code examples
iosswiftswift2screenuitouch

How to Count the number of times the screen be touched in swift?


How to get the number of times the screen be touched in swift I don't

know which method to use, please help


Solution

  • It is quite simple, just declare a counter at top, var counter = 0

    then use the function, just type touchesBegan it will show

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        counter++
        print(counter)
    }