iphone - AVAudioPlayer 错误加载文件

标签 iphone objective-c ios avaudioplayer

我正在尝试使用 AVAudioPlayer 播放简单的声音,但我一直在控制台中收到此错误:

2011-09-02 20:29:07.369 MusicLog[967:10103] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security

这是我的代码,当我按下按钮时应该播放声音:

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"tick" ofType:@"caf"];
NSError *error;

    NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
    AVAudioPlayer *tickPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:&error];
[tickPlayer setDelegate:self];
[tickPlayer setNumberOfLoops:0];
[tickPlayer prepareToPlay];
if (tickPlayer == nil)
{
    NSLog(@"%@", [error description]);
}
else
{
    [tickPlayer play];
}

我是不是把文件放在了错误的地方?我只是将文件拖到项目中,并根据需要选择副本。

编辑:经过更多测试后,我发现在运行 IOS 4.2 模拟器时不会出现此错误,仅在 IOS 5 模拟器上出现。我可以假设这是 iOS 5 中的错误吗?

谢谢,

最佳答案

我遇到了同样的问题。这似乎只是模拟器中 iOS5 上的问题。我还没有在 iOS 5 设备上测试过。我一直希望 XCode 升级会消除错误,但到目前为止运气不好。

关于iphone - AVAudioPlayer 错误加载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7290418/

相关文章:

objective-c - didReceiveRemoteNotification 和角标(Badge)编号

iphone - 无需连接即可为 iPhone 构建

objective-c - NS表达式 1/2

ios - 播放器 SKPhysicsBody 通过其他 SKPhysicsBody swift 4 Xcode 9

ios - IBAction 在升级到(SDK 8.1,Xcode 6)后没有被调用

iphone - 调整 iPhone 键窗口主视图的大小

ios - -E 或 - x 当输入来自标准输入时需要

iphone - 媒体播放器框架不在 iOS 6 中播放视频

iphone - 仅将图像保存到自定义相册

iphone - 是否可以向系统搜索提供有关我的应用程序的其他信息?