我正在尝试在 xcode 中编写最简单的“按下按钮并听到声音”设置,但我仍然设法得到一些神秘的错误。这是我的代码:
在 .h 文件中:
#import <AVFoundation/AVFoundation.h>
在 .m 文件中:
- (IBAction)beepButton:(UIButton *)sender {
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"buttonBeep"
ofType:@"mp3"]];
AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[click play];
//[click release];
}
当我尝试编译我的应用程序时,出现以下错误:
Undefined symbols for architecture armv7s:
"_OBJC_CLASS_$_AVAudioPlayer", referenced from:
objc-class-ref in MyFirstViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
难道我做错了什么?任何帮助表示赞赏!