xcode - ViewController.Type does not have a member named -
just simple task, i'm in trouble. trying make different way fails.
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
Post a Comment