2012-03-16 748 views
1

我在if語句中以紅色statement requires expression of scalar type ('void' invalid)得到警告消息。聲明需要表達標量類型('void'無效)

- (void)displayviewsAction:(id)sender 
{ 
    FirstViewController *viewController = [[FirstViewController alloc] init]; 
    viewController.view.frame = CGRectMake(0, 0, 320, 480); 
    [self.view addSubview:viewController.view]; 
    [self.view addSubview:toolbar]; 

    if ([audioPlayer pause]){ 
     [timer invalidate]; 
    } else { 
     self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(secondViewController) userInfo:nil repeats:NO]; 
    } 
    [viewController release]; 
} 

任何想法如何解決它。

感謝您的幫助。

+0

因此,沒有audioPlayer返回一個值? – 2012-03-16 23:37:18

回答

0

看起來像[audioPlayer pause]不返回任何值。

假設audioPlayerMPMusicPlayerController一個實例,嘗試

if(audioPlayer.playbackState == MPMusicPlaybackStatePaused) 
+0

我正在使用AVAudioPlayer,我不認爲AVAudioPlayer有任何屬性播放狀態。 – user1120133 2012-03-16 23:47:16

+0

然後你必須檢查是否([audioPlayer isPlaying])然後[audioPlayer暫停] – dzeikei 2012-03-17 00:24:25

相關問題