【发布时间】:2016-01-02 03:36:55
【问题描述】:
以下代码产生以下错误。 不知道为什么?
NSString *soundFilePath = [NSString stringWithFormat:@"%@/abc.m4a",
[[NSBundle mainBundle] resourcePath]];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL
error:nil];
player.numberOfLoops = -1; //Infinite
[player play];
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_AVAudioPlayer", referenced from:
objc-class-ref in BasicArithmaticViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
【问题讨论】:
-
需要的框架:/system/library/frameworks/avfoundation.framework
-
仅供参考 - 不要使用您问题中的代码获取路径。使用
NSURL *soundFileURL = [[NSBundle mainBundle] URLForResource:@"abc" withExtension:@"m4a"];。 -
好的...没有错误...但也没有声音
-
这工作“AudioServicesPlaySystemSound(1005);”但仍然无法让 AVAudioPlayer 工作