- (IBAction) btnFire:(id)sender {
NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/gunShot.wav"];
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AVPlayer *shotSound = [[AVPlayer alloc] initWithURL:filePath];
[shotSound play];
}
如果我在这里释放shotSound,它不会不玩。同时没有泄漏。
为什么仪器显示无泄漏?如何释放shotSound?
这样有什么缺点吗? – Michael 2011-04-14 08:16:30
如果你只想播放一个文件,我认为这就足够了。当你这样做时,当AutoReleasePool排空时,玩家获得释放 – visakh7 2011-04-14 09:31:21