title: Problem invalidating NSTimer in dealloc
body: <p>Following is my code:</p>
  
  <p>.h file:</p>
  
  <pre><code>#import "Foundation/Foundation.h"
  @interface GObject:NSObject{
      NSTimer* m_Timer;
  }
  @property(nonatomic, retain) NSTimer* m_Timer;
  
  - (void)Initialize;
  - (void)TimerCallback:(NSTimer*)pTimer;
  @end
  </code></pre>
  
  <p>.m file:</p>
  
  <pre><code>@implementation GObject
  
  @synthesize m_Timer
  
  - (void) Initialize{
      self.m_Timer = [NSTimer scheduledTimerWithTimeInterval:5.0 
                         target:self 
                         selector: @selector(TimerCallback:) 
                         userInfo: nil 
                         repeats: YES];
  
  }
  
  - (void)TimerCallback:(NSTimer*)pTimer {
      //Some Code
  }
  - (void)dealloc {
      [m_Timer invalidate]; //--Crashes Here
      [m_Timer release];
      m_Timer = nil;
      [super dealloc];
  }
  @end
  </code></pre>
  
  <p>Now when the dealloc gets called, the program crashes in the line invalidating the timer. The next two lines don't even get called. I get a "EXC_BAD_ACCESS" error. Can anyone tell me why that might be happening, and what is the proper way of stopping and releasing a NSTimer member variable in a class.</p>