1
我正在使用AudioToolbox
和SystemSoundID
加載和播放聲音。正確釋放系統聲音ID
這裏是我的代碼在我viewDidLoad
方法:
NSString *swipeFilePath = [[NSBundle mainBundle] pathForResource:@"swipe" ofType:@"caf"];
NSURL *swipeFileURL = [NSURL fileURLWithPath:swipeFilePath];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)swipeFileURL, &swipe);
每次我需要它來打我做到以下幾點:
AudioServicesPlaySystemSound(swipe);
我知道,因爲它不是一個OBJ我必須釋放自己-c對象,但我不確定如果我正確地做到了。
我所做的就是以下,但它產生的錯誤是什麼:
- (void)dealloc {
AudioServiceDisposeSystemSoundID(swipe);
}
警告:的功能隱式聲明「AudioServiceDisposeSystemSoundID」是C99
什麼是釋放的適當方式無效我聲音?
哎呦!你是對的,一切工作正常!不能相信我錯過了! – KingPolygon 2014-10-22 03:57:17
很高興我幫助,享受! – 2014-10-22 03:58:33