Run Timer for first time and resume timer for second time
<p>Declared variable in m file.</p>

<pre><code>BOOL isFirstTime;
</code></pre>

<p>I want that if play button is pressed the very first time then it should toggle to pause button and check the function <code>isFirstTime</code> then it should start the timer and execute the <code>displayviewsAction</code> method and if the pause button is resumed to play back then it should check again the function <code>isFirstTime</code> or second time and if the hit is for the second time then it should resume timer.</p>

<pre><code>-(void)playpauseAction:(id)sender {
if ([audioPlayer isPlaying]){         
   [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
   [audioPlayer pause];
   [self pauseTimer];
} else {
  [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
  [audioPlayer play];
  [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(AfterOneSecondsFuction) userInfo:nil repeats:YES];
        }         
}
-(void)pauseTimer{
pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain];
previousFireDate = [[timer fireDate] retain];
[timer setFireDate:[NSDate distantFuture]];
}
 -(void)resumeTimer{
float pauseTime = -1*[pauseStart timeIntervalSinceNow];
[timer setFireDate:[previousFireDate initWithTimeInterval:pauseTime sinceDate:previousFireDate]];
[pauseStart release];
[previousFireDate release];    
}
-(void)AfterOneSecondsFuction
{
if(!isFirstTime)
{
 isFirstTime=YES;
 return;
 self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
                                                  target:self
                                                selector:@selector(displayviewsAction:)
                                                userInfo:nil
                                                repeats:NO];

} else if (!isFirstTime){
  isFirstTime=NO;
  return;
  [self resumeTimer]; 

     }
}    

- (void)displayviewsAction:(id)sender
{  
  First *firstController = [[First alloc] init];
firstController.view.frame = CGRectMake(0, 0, 320, 480);
CATransition *transitionAnimation = [CATransition animation];   
[transitionAnimation setDuration:1];
[transitionAnimation setType:kCATransitionFade];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction     functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade];
[self.view addSubview:firstController.view];
[self.view addSubview:toolbar];
[firstController release];   
}

-(void)Second 
{
 Second *secondController = [[Second alloc] init];
secondController.view.frame = CGRectMake(0, 0, 320, 480);
CATransition *transitionAnimation = [CATransition animation];
[transitionAnimation setDuration:1];
[transitionAnimation setType:kCATransitionReveal];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionReveal];
[self.view addSubview:secondController.view]; 
[self.view addSubview:toolbar];
[secondController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
 }
</code></pre>

<p>Looks like when play is pressed first it is only toggling to pause button not checking the function <code>isFirstTime</code> or not and not starting the timer and executing displayviewsaction.</p>

<p>If anyone can tell why it is not happening and what i m doing wrong.</p>

<p>Thanks for help.</p>
