Tuesday, 15 February 2011

ios - How to get an NSTimer to stop repeating after a condition is met -



ios - How to get an NSTimer to stop repeating after a condition is met -

this question has reply here:

how stop nstimer 6 answers

i have 2 nstimers programmed have button appear on screen , disappear. how can programme stop adding , removing buttons 1 time status met?

here code:

var timerremovebutton = nstimer.scheduledtimerwithtimeinterval(1.0, target: self, selector: "removebutton", userinfo: nil, repeats: true) var timeraddbutton = nstimer.scheduledtimerwithtimeinterval(1.0, target: self, selector: "addbutton", userinfo: nil, repeats: true)

you can invalidate them in usual objective-c. when status met write:

timerremovebutton.invalidate() timeraddbutton.invalidate()

this remove timers nsrunloop object.

ios swift nstimer

No comments:

Post a Comment