2011-04-30 18 views
0

我正在製作一個暫停和播放聲音的按鈕。這裏是我的編碼:錯誤:'else'之前的預期表達式

.H:

@interface RootViewController : UIViewController { 
} 
@property (nonatomic, retain) AVAudioPlayer *theAudio; 
-(IBAction)pause; 

@end 

.M:

- (void)viewDidLoad { 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"MathMusic1" ofType:@"wav"]; 
    self.theAudio = [[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL] autorelease]; 
    theAudio.delegate = self; 
    [theAudio play]; 
    theAudio.numberOfLoops = -1; 

    [super viewDidLoad]; 


} 

現在我試圖讓一個按鈕,所以這裏暫停這是編碼:(已經在聲明.H)

-(IBAction)pause { 

    [theAudio pause]; 




    else // expected expression before 'else' 
    [theAudio play]; 

} 

/錯誤:前預期表達 '中的其他'

回答

0

有一個else沒有if(就在之前),我認爲這可能是你的代碼中的錯誤。

0

您沒有if聲明。

相關問題