xcode - ViewController.Type does not have a member named -


just simple task, i'm in trouble. trying make different way fails.

enter image description here

how init nstimer declared variable? neither var nor let helps.

the initial value of property (in case: timer) cannot depend on property of class (in case: interval).

therefore have move assigment timer = nstimer(interval, ...) method of class, e.g. viewdidload. consequence, timer has defined optional or implicitly unwrapped optional.

note selector(...) takes literal string argument, not method itself.

so should work:

class viewcontroller: uiviewcontroller {      var interval : nstimeinterval = 1.0     var timer : nstimer!      func timerredraw() {      }      override func viewdidload() {         super.viewdidload()         timer = nstimer(timeinterval: interval, target: self, selector: selector("timerredraw"), userinfo: nil, repeats: true)          // ...     }      // other methods ... } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -