Making a button play and pause background sound
I have errors with my code:
-(IBAction)pause {
[theAudio pause];
if [theAudio pause] {
else 开发者_如何学Go{
[theAudio play];
}
}
}
I am very new to c and xcode and I am really not sure what to do. Please provide the right code in relation to this.
i suggest you team up with user 722566, and work through problems together:
https://stackoverflow.com/questions/5838749/error-expected-before-token-and-expected-declaration-or-statement-at-end
Making a button play and pause background sound
error: expected expression before 'else'
it seems like you two have a lot of identical questions, at approximately the same time.
thanks
The code you posted has some syntax errors, it should look like the following:
-(IBAction)pause {
if ([theAudio isPaused]) {
[theAudio play];
} else {
[theAudio pause];
}
}
I have no idea if your theAudio
object has an isPaused
method, basically in the if statement you should be checking whether the audio is playing or not, and use that to set the audio to play or pause.
精彩评论