title: NSTimer doesn't stop
body: <p>I've got a timer which fires when the <code>viewWillAppear</code> method is being called and invalidates when the <code>viewDidDisappear</code> method is being called. But after a certain amount of switching between views the timer continues firing even after it was invalidated. What's the problem?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>NSTimer *timer;
  
  - (void)viewWillAppear:(BOOL)animated {
      [super viewWillAppear:animated];
      timer = [NSTimer scheduledTimerWithTimeInterval: 0.2f
                       target: self
                       selector:@selector( timerAction )
                       userInfo:nil
                       repeats:YES];
  }
  
  -(void)viewDidDisappear:(BOOL)animated {
      [super viewDidDisappear:animated];
      [timer invalidate];
      timer = nil;
  }
  
  -(void) timerAction
  {
      NSLog(@"timerAction");
  }
  </code></pre>