NSSound 在 iPhone 上未声明?
sound = [[NSSound alloc] initWithContentsOfFile:@"staticbeam09.wav" byReference:YES];
代码引用自 Apple 文档。当我将其放入 viewDidLoad 时出现错误。如果我放入
NSSound *sound;
头文件,我会在实现文件的顶部收到说明符限定符错误。我需要做什么才能使这项工作成功?我只是粘贴 Apple 文档中的代码 - 这是否已被弃用?感谢您的帮助!
sound = [[NSSound alloc] initWithContentsOfFile:@"staticbeam09.wav" byReference:YES];
Code referenced from Apple docs. Getting an error when I put this in viewDidLoad. If I put
NSSound *sound;
in the header file, I get the specifier-qualifier error at the top of my implementation file. What do I have to do to make this work? I was just pasting the code from Apple's documentation - has this been deprecated? Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
iPhone SDK中没有NSSound类
仅适用于 MacOS
There is no NSSound class in iPhone SDK
It's only for MacOS
氧气说得对。如果您想在 iPhone 上播放声音,有多种选择。可能最简单的一种是使用音频服务(示例包装器),然后是AVAudioPlayer 然后你也可以使用 OpenAL (我已经写了一个非常基本的 OpenAL 音效引擎,称为 Finch)。取决于你需要做什么。
Oxigen’s right. If you want to play sounds on iPhone, there are several options. Probably the easiest one is using Audio Services (example wrapper), then there is AVAudioPlayer and then you can also use OpenAL (I’ve written a very basic OpenAL sound effect engine called Finch). Depends on what you need to do.
http://icodeblog .com/2009/05/04/iphone-game-programming-tutorial-part-4-basic-game-audio/
这就是我最后为 iconquer 制作音频背景音乐和音效的方式
http://icodeblog.com/2009/05/04/iphone-game-programming-tutorial-part-4-basic-game-audio/
that is how i did the audio bg music and sound effects at the end for iconquer