iphone - NSTimer getting zombie -


i have created nstimer in application gets fired after every 1 min interval. problem when put application in background , after time 5 min, bring in foreground, timer object gets zombied.

any thoughts on this.

perhaps invalidate timer when application enters background start again when application enters foreground.

like so:

- (void)applicationdidenterbackground:(uiapplication *)application {     [mytimer invalidate]; }  - (void)applicationwillenterforeground:(uiapplication *)application {     mytimer = [nstimer scheduledtimerwithtimeinterval:60.0 target:self selector:@selector(timerfunction) userinfo:nil repeats:yes]; } 

Comments