swift - Is it possible to set a struct as target for NSTimer -


i trying set scheduledtimerwithtimeinterval inside struct keep getting error cannot invoke scheduledtimerwithtimeinterval argument list of type. when change struct class works fine.

my question possible set struct target of nstimer? api says should of type anyobject

struct mytimer{     init() {         let timer = nstimer.scheduledtimerwithtimeinterval(1, target: self, selector: selector("timer"), userinfo: nil, repeats: true)     } } 

and

class mytimer{     init() {         let timer = nstimer.scheduledtimerwithtimeinterval(1, target: self, selector: selector("timer"), userinfo: nil, repeats: true)     } } 

edit: seems class target of scheduledtimer has inherit nsobject first. struct never that.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -