objective c - Does NSTimer run across entire app? -


if start nstimer this:

@property (strong) nstimer * messagetimer;   self.messagetimer = [nstimer scheduledtimerwithtimeinterval:10.0                                      target:self                                    selector:@selector(checkformessages)                                    userinfo:nil                                     repeats:yes]; 

does continue run when switch different view controllers?

until cancel with:

[messagetimer invalidate]; self. messagetimer = nil;  

yes.

okay, here extended description. nstimer registers on nearest nsrunloop, is, current dispatch loop (they may nest). loop asks various sources events , calls corresponding callbacks.

when time nstimer fire, returns yes nsrunloop , runs passed callback. there no such thing "other current view controller". first responder , view hierarchy, neither doesn't have effect on run loops.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -