0

为在 iPhone 设备上测试应用程序而按两次倒带时应用程序崩溃并显示消息[__NSDate timeIntervalSinceNow]: message sent to deallocated instance

-(void)pauseTimer{
pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain];

previousFireDate = [[timer fireDate] retain];

[timer setFireDate:[NSDate distantFuture]];
}


-(void)dealloc
{
[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];
}else{
    [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
                                                      target:self
                                                    selector:@selector(displayviewsAction:)
                                                    userInfo:nil
                                                     repeats:NO];
        isFirstTime  = NO;
    }
   } 
   }


 -(void)rewind:(id)sender{
[timer invalidate];
audioPlayer.currentTime = 0;
MainViewController *viewController = [[[MainViewController alloc] init]autorelease];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view]; 
[self.view addSubview:toolbar];
[self playpauseAction:_playButton];
}

当再次按下倒带按钮并故意在 iphone 设备上测试应用程序时,应用程序崩溃并给出消息[__NSDate timeIntervalSinceNow]: message sent to deallocated instance

任何想法有什么问题。

感谢帮助。

谢谢。

4

1 回答 1

0

已移除

 [pauseStart release];
  [previousFireDate release];

从 dealloc 方法。

这解决了我的问题。

于 2012-06-27T15:28:01.773 回答