Take the 2-minute tour ×

App crashed with the message when hitting rewind twice just to test app on iPhone device [__NSDate timeIntervalSinceNow]: message sent to deallocated instance

pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain];

previousFireDate = [[timer fireDate] retain];

[timer setFireDate:[NSDate distantFuture]];

[audioPlayer release];
[pauseStart release];
[previousFireDate release];
[super dealloc];

  -(void)playpauseAction:(id)sender {

if([audioPlayer isPlaying])
    [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
    [audioPlayer pause];
    [self pauseTimer];
    [self pauseLayer:self.view.layer];
    [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
    [audioPlayer play];
    [self resumeTimer];
    [self resumeLayer:self.view.layer];

    if(isFirstTime == YES)
        self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
        isFirstTime  = NO;

[timer invalidate];
audioPlayer.currentTime = 0;
MainViewController *viewController = [[[MainViewController alloc] init]autorelease];
[self.view addSubview:viewController.view]; 
[self.view addSubview:toolbar];
[self playpauseAction:_playButton];

when hitting rewind button again and purposely to test app on iphone device app crashes and gives message [__NSDate timeIntervalSinceNow]: message sent to deallocated instance

Any ideas what is wrong.

Appreciate help.


share|improve this question
Are there places in your code that you call timeIntervalSinceNow (not dateWithTimeIntervalSinceNow)? –  Phillip Mills Jun 27 '12 at 14:14
-(void)resumeTimer{ float pauseTime = -1*[pauseStart timeIntervalSinceNow]; [timer setFireDate:[previousFireDate initWithTimeInterval:pauseTime sinceDate:previousFireDate]]; } –  user1452248 Jun 27 '12 at 14:16
OK, so pauseStart is probably the problem...how is it defined? ...and are there other places where it's being released? –  Phillip Mills Jun 27 '12 at 14:21
in the m file of mainviewcontroller defined it NSDate *pauseStart, *previousFireDate; releasing it in only dealloc method –  user1452248 Jun 27 '12 at 14:23
Hmmm. That suggests you'll have a memory leak if you call pauseTimer twice before this object is deallocated...but that doesn't explain your problem. Sorry. –  Phillip Mills Jun 27 '12 at 14:29

1 Answer 1


 [pauseStart release];
  [previousFireDate release];

from the dealloc method.

That solved my problem.

share|improve this answer
I think you'll find you are just hiding one issue and creating another, namely a memory leak. –  Mike Weller Jun 27 '12 at 15:32
I guess you are right in Instruments getting the memory leak for NSDate –  user1452248 Jun 27 '12 at 15:40
Responsible frames for NSDate leak is resume Timer and pauseTimer. How can i fix this. If you can be of any help. Will appreciate so much. –  user1452248 Jun 27 '12 at 15:44

Your Answer


