0
我有一個方法AudioServicesCreateSystemSoundID,根據文檔似乎需要傳入的內存地址(* outSystemSoundID)。AudioServicesCreateSystemSoundID和內存地址參數 - 如何傳入屬性?
從蘋果公司的網站......
OSStatus AudioServicesCreateSystemSoundID (
CFURLRef inFileURL,
SystemSoundID *outSystemSoundID
);
我有這樣的代碼時,我創建方法內的局部對象,它的工作原理。該對象正確分配給內存位置。
這將返回MYTEST代碼爲:0(這就是我想要的)
SystemSoundID thisSoundID;
SystemSoundID myTest = AudioServicesCreateSystemSoundID
(
(__bridge CFURLRef)(url), &thisSoundID
);
但是,這就是我要做的。 (self.theSound我已設置爲SystemSoundID屬性)。
這將返回MYTEST,錯誤代碼:4294967246(我不想此)
SystemSoundID myTest = AudioServicesCreateSystemSoundID
(
(__bridge CFURLRef)(url), self.theSound
);
好的答案。你會碰巧知道對_的引用嗎?「..你不能接受一個屬性的」地址「並將它傳遞給一個函數,你可以通過實例變量的地址來代替。」_?我隱約記得很久以前在某個地方讀過這篇文章,但我不記得在哪裏。我想就此進行一些修改。提前致謝。 – Unheilig
這適用於成功創建對象。然而它似乎並沒有在功能之外持續存在。 IE瀏覽器。如果我在函數內部調用完全相同的方法,那麼函數外面就沒有任何工作。 'code AudioServicesPlaySystemSound(*(self.theSound)); //作品後立即進行。但是,下列情況並不會... - (void)playSound { NSLog(@「Called playSound」); AudioServicesPlaySystemSound(*(self.theSound)); } –
@FannyDarmer:爲什麼'AudioServicesPlaySystemSound(*(self.theSound))'?不應該是'AudioServicesPlaySystemSound(self.theSound)'? –