ios - Why does my NSTimer selector never fire? Is it because it's in GLKitViewController instead of UIViewController? -
at state in program, call method body:
self.timestarteddisplayingtime = [nsdate date]; self.stopbutton.enabled = yes; [nstimer scheduledtimerwithtimeinterval:0.01 target:self selector:@selector(updateelapsedtime:) userinfo:nil repeats:yes];
i've verified method indeed called.
however, corresponding selector's body:
nstimeinterval elapsedtimedisplayingecg = [self.timestarteddisplayingecg timeintervalsincedate:[nsdate date]]; self.elapsedtimevaluelabel.text = [nsstring stringwithformat:@"%f", elapsedtimedisplayingecg];
is never called. i've put breakpoint on , it's never reached. why exactly? it's in glkitviewcontroller instead if that's relevant.
your timer gets thrown away right after creating it. need retain somewhere.
define property
@property (strong) nstimer *mytimer;
and assign timer this:
self.mytimer = [nstimer scheduledtimer scheduledtimerwithtimeinterval:0.01 target:self selector:@selector(updateelapsedtime:) userinfo:nil repeats:yes];
Comments
Post a Comment