- (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