如何访问crashSound.wav
我放在 xCode 项目的 Supporting Files 文件夹中的文件?因为以下代码不起作用:
@interface Game()
{
// code...
AVAudioPlayer *crashSound;
// code...
}
@end
@implementation Game
- (id) init
{
// code...
NSURL *crashSoundFile = [[NSURL alloc] initWithString:@"crashSound" ]; // <--PROBLEM
crashSound = [[AVAudioPlayer alloc] initWithContentsOfURL:crashSoundFile error:NULL];
// code...
}
-(void) play // this is my "main" method that will be called once the playButton is pressed
{
[crashSound play];[crashSound play];[crashSound play];
}
@end