In an attempt to fix a memory leak, I am trying to implement this code in my .m file:
AVAudioPlayer *audioPlayer;
- (AVAudioPlayer *)audioPlayerWithContentsOfFile:(NSString *) path {
NSData *audioData = [NSData dataWithContentsOfFile:path];
AVAudioPlayer *player = [AVAudioPlayer alloc];
if([player initWithData:audioData error:NULL]) {
[player autorelease];
} else {
[player release];
player = nil;
}
return player;
}
Then attempting to call it via:
[audioPlayer audioPlayerWithContentsOfFile: [NSString stringWithFormat:@"%@/knock_knock.wav", [[NSBundle mainBundle] resourcePath]]];
Header file has:
- (AVAudioPlayer *) audioPlayerWithContentsOfFile: (NSString *) path;
Compiles with one warning: AVAudioPlayer may not response to '-audioPlayerWithContentsOfFile:' (Messages without a matching signature will be assumed to return 'id' and accept '...' as arguements.
Everytime I thing I am getting this language, I run into stuff like this that I spend hours trying to figure out. Anyone able to help? As always, thanks in advance.
Geo...