0

I am doing an iOS app using Swift 4 but I am struggling to find how to execute a certain amount of code every minute.

There is a timer in my app which calculate the difference between the starting time and the current time and I should update a label with the result every minute.

I think that I should use scheduledTimer(timeInterval:target:selector:userInfo:repeats:) but I don't understand how should I implement it.

By trying with the answer of Unheilig with

var helloWorldTimer = Timer.scheduledTimer(timeInterval: 60.0, target: self, selector: #selector(ViewController.sayHello), userInfo: nil, repeats: true)

        func sayHello()
        {
            NSLog("hello World")
        }

I got the error Type 'ViewController' has no member 'sayHello'

Julien
  • 159
  • 2
  • 16

0 Answers0