tags:

views:

30

answers:

1

I get this error, and I dont get how to fix it?

class 'SoundTap_HDViewController' does not implement the 'AVAudioPlayerDelegate' protocol

Any help?

+2  A: 

If you are going to conform to a protocol, you need to implement its required methods. AVAudioPlayerDelegate has no required methods, so you may be trying to call a delegate method without adding the protocol. Does your class look something like:

@interface SoundTap_HDViewController : NSObject <AVAudioPlayerDelegate>

Protocols are listed between the <> and separated by commas.

Typeoneerror
Hmm, is that right for this code:-(IBAction)playSound { NSString *path = [[NSBundle mainBundle] pathForResource:@"airhorn" ofType:@"wav"]; AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; theAudio.delegate = self; [theAudio play];
Henry D'Andrea
@Henry. Why don't you just try it? "<AVAudioPlayerDelegate>" has 23 characters in it - far fewer than the number in your comment :)
JeremyP
@Henry. So you're assigning "self" as the delegate of the theAudio, so whatever "self" is should implement the AVAudioPlayerDelegate protocol as I indicated in the answer.
Typeoneerror
Hmmm Doesnt work in my .h file
Henry D'Andrea
Sorry, mate, you'll have to post more code. Can't do much with "doesn't work." :)
Typeoneerror