我正在使用音频工具箱
.h 文件
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface ViewController : UIViewController {
}
-(IBAction)buttonPressedWithSound:(id)sender;
@end
并在 .m 文件中
-(IBAction)buttonPressedWithSound:(id)sender {
int randomSoundNumber = arc4random() % 4; //random number from 0 to 3
NSLog(@"random NR = %i", randomSoundNumber);
NSString *effectTitle;
switch (randomSoundNumber) {
case 0:
effectTitle = @"Come at me BRO!";
break;
default:
break;
}
SystemSoundID soundID;
NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"mp3"];
NSSound *sound = [[[NSSound alloc] initWithContentsOfFile: soundPath byReference: NO] autorelease];
[sound play];
AudioServicesCreateSystemSoundID ((CFURLRef)CFBridgingRetain(soundUrl), &soundID);
AudioServicesPlaySystemSound(soundID);
}
但是当我在我的 iphone 上运行时,它出现在 AUGraph.h 中的日志中,其中 #include AudioUnit/AudioUnit.h 和“AudioUnit/AudioUnit.h”文件在它的右侧找不到。
我该如何解决这个问题才能在我的手机上运行它?