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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -