In my MyDocument class I have these two methods:
setupTimer is called from windowControllerDidLoadNib. My problem is that when I close the window the NSTimer keeps firing the updateDatePickers method, causing the program to crash. I have tried invalidating and releasing the time in my classes dealloc method, but this doesn't work. Doers anyone know how to stop the timer from firing when the window is closed?
Code:
- (void)setupTimer:(id)sender
{
timer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateDatePickers:)
userInfo:nil
repeats:YES];
}
- (void)updateDatePickers:(NSTimer *)aTimer
{
NSDate *temp = [NSDate date];
[currentDate setDateValue:temp];
}
setupTimer is called from windowControllerDidLoadNib. My problem is that when I close the window the NSTimer keeps firing the updateDatePickers method, causing the program to crash. I have tried invalidating and releasing the time in my classes dealloc method, but this doesn't work. Doers anyone know how to stop the timer from firing when the window is closed?