title: How to pause and restart an NSTimer when view disappears?
body: <p>I am using an <code>NSTimer</code> in my view class that is called every 15 seconds. My problem is, it is working properly, but my app is getting slow, because it is showing its performance to the whole app. So I want to pause the <code>NSTimer</code> when my view disappears from its superview and restart the timer when it appears. Please help me in solving the problem. Here is my code:</p>
  
  <pre><code>- (void) viewWillAppear:(BOOL)animated
  {
  
      if(!Thread_bool)
      {
          //[spinner startAnimating];
          NSTimer *timer_new1=[[NSTimer alloc] init];
          timer_new1=[NSTimer scheduledTimerWithTimeInterval:2.0 target:self                selector:@selector(threadMethod) userInfo:nil repeats:YES];
          self.timer_new=timer_new1;
          [timer_new1 release];
          [self.tableView setEditing:NO];
          isEditing=NO;
          Thread_bool=YES;    
      }
  }
  
  -(void)viewWillDisappear:(BOOL)animated
  {
      [self.timer_new invalidate];
      timer_new=nil;  
  }
  </code></pre>