iphone - No Known class method for selector 'myTimer' -
have 2 view controllers oneviewcontroller , mainviewcontroller. in oneviewcontroller defined mytimer. in mainviewcontroller m trying pause , resume mytimer using uibutton. getting message no known class method selector 'mytimer'
in oneviewcontroller defined nstimer mytimer
@property (nonatomic, retain) nstimer *mytimer; @synthesize mytimer; - (void)viewdidload { [self mytimermethod]; [super viewdidload]; } - (void)mytimermethod{ nslog(@"mytimermethod called"); mytimer = [nstimer scheduledtimerwithtimeinterval:2.4 target:self selector:@selector(updateview:) userinfo:nil repeats:yes]; } - (void)updateview:(nstimer *)thetimer { if (index < [textarray count]) { self.textview.text = [self.textarray objectatindex:index]; self.imageview.image = [self.imagesarray objectatindex:index]; index++; }else{ index = 0; }
i m trying pause , resume mytimer mainviewcontroller
in mainviewcontroller.h
@class oneviewcontroller; @property (strong, nonatomic) oneviewcontroller *oneviewcontroller; @synthesize oneviewcontroller = _oneviewcontroller; -(void)playpauseaction:(id)sender { if([audioplayer isplaying]) { [sender setimage:[uiimage imagenamed:@"music.png"] forstate:uicontrolstatenormal]; [audioplayer pause]; [[oneviewcontroller mytimer] invalidate]; **\\no known class method selector 'mytimer'** }else{ [sender setimage:[uiimage imagenamed:@"audiostop.png"] forstate:uicontrolstatenormal]; [audioplayer play]; [[oneviewcontroller mytimer] fire]; **\\no known class method selector 'mytimer'** if(isfirsttime == yes) { self.timer = [nstimer scheduledtimerwithtimeinterval:06.0 target:self selector:@selector(displayviewsaction:) userinfo:nil repeats:no]; isfirsttime = no; } } }
how can prepare error.
thanks help.
instead of [[oneviewcontroller mytimer] invalidate];
utilize [self.oneviewcontroller.mytimer invalidate];
also, in oneviewcontroller implementation, instead of mytimer = [nstimer scheduledtimerwithtimeinterval:.....
utilize self.mytimer = [nstimer scheduledtimerwithtimeinterval:.....
iphone objective-c cocoa-touch ios6
No comments:
Post a Comment