I am making a button that pauses and plays a sound. Here is my coding:
.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];
}
Now i am trying to make a button to pause this so here is that coding: (Already declared in .h)
-(IBAction)pause {
[theAudio pause];
else // expected expression before 'else'
[theAudio play];
}
/ error: expected expression before ‘else’
There is an
elsewithout anif(just before), I think it may be the error in your code.