内存泄漏在试图修复内存泄漏,我想在我的.m文件来实现此代码:试图修复使用AVAudioPlayer
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;
}
然后试图通过叫它:
[audioPlayer audioPlayerWithContentsOfFile: [NSString stringWithFormat:@"%@/knock_knock.wav", [[NSBundle mainBundle] resourcePath]]];
头文件具有: AVAudioPlayer不得响应:
- (AVAudioPlayer *) audioPlayerWithContentsOfFile: (NSString *) path;
与一个警告编译到'-audioPlayerWithContentsOfFile:' (没有匹配签名的消息将被认为返回'id'并接受'...'作为参数。
每当我遇到这种语言时,我会遇到这样的事情,我花了数小时试图弄清楚。任何人都可以帮忙?一如既往,先谢谢你。
地理...
关于你的答案的第一部分:乔治没有张贴的由来代码,因此你缺乏上下文。看到这里:http://blog.zincroe.com/2009/06/avaudioplayer-memory-leak/否则,+1。 – 2011-05-23 13:20:28