我想要播放声音,但是当我编码时:
AudioServicesCreateSystemSoundID ((CFURLRef) alertSound, &soundFileObject);
Run Code Online (Sandbox Code Playgroud)
它会引发以下错误:
将Objective-C指针类型'NSURL*'转换为C指针类型'CFURLRef'(又名'const struct __CFURL*')需要桥接转换错误
我尝试了以下两个建议的解决方案:
AudioServicesCreateSystemSoundID ((__bridge CFURLRef) alertSound, &soundFileObject);
Run Code Online (Sandbox Code Playgroud)
要么
AudioServicesCreateSystemSoundID ((CFURLRef) CFBridgingRetain(alertSound), &soundFileObject);
Run Code Online (Sandbox Code Playgroud)
但我仍然无法发挥声音.
我想问题是:声音不起作用的桥接错误,还是我应该在哪里寻找其他地方?
我可以使用SysSound示例代码播放声音,我使用的是iOS 6和Xcode 4.5.
感谢任何指针:)