Reputation: 878
in my code:
#import "MyViewController.h"
#import "AVFoundation/AVAudioPlayer.h"
- (IBAction)playSound{
AVAudioPlayer *myExampleSound;
NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"];
myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL];
myExampleSound.delegate = self;
[myExampleSound play];
}
But it is showing a warning that Class MyViewController does not implement AVAudioplayerDelegate.
Anyone please help. I had included the AVFoundation.Framework.
Upvotes: 0
Views: 267
Reputation: 18132
That warning should not affect the actual function of the code.
If you want to suppress the warning, in the header of your view controller do this:
@interface MyViewController : UIViewController <AVAudioPlayerDelegate> {
This lets the compiler know that your class does respond to the AVAudioPlayerDelegate (even though all the methods in that protocol are optional). See here.
Upvotes: 2