简体   繁体   中英

NSSound undeclared on iPhone?

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!

iPhone SDK中没有NSSound类,仅适用于MacOS

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/

that is how i did the audio bg music and sound effects at the end for iconquer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM