objective-c - 为什么我得到这个 : _cfurl: unrecognized selector

标签 objective-c ios audiotoolbox

我的初始化是这样开始的:

- (id) init {
    [super init];
    sounds = makeDictFromArrayOfURLs(getNoiseFileURLs());
    [sounds retain];
    NSURL *theFirstNoise = [[sounds allKeys] objectAtIndex:0];
    CFURLRef uref = (CFURLRef)theFirstNoise;
    OSStatus ret = AudioServicesCreateSystemSoundID(uref, &chosenNoise);

当我们到达最后一行时,它抛出这个:

2011-06-09 23:19:18.744 SuperTimer[94516:207] -[NSPathStore2 _cfurl]: unrecognized selector sent to instance 0x940cfb0
2011-06-09 23:19:18.746 SuperTimer[94516:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSPathStore2 _cfurl]: unrecognized selector sent to instance 0x940cfb0'

是的,它对于调试来说有点不紧凑。

就在我得到转储之前,theFirstNoise 包含预期的(某种)数据。 (它的 description 方法打印出一个奇怪的形式,但我被告知这是正常的。)

最佳答案

在我的脑海中,看起来 theFirstNoise 实际上是一个 NSPathStore2(NSString 的私有(private)子类)而不是一个 NSURL

编辑:NSPathStore2 对象将包含文件路径。如果您需要将它们转换为 NSURL,只需将它们传递给 +[NSURL fileURLWithPath:]

关于objective-c - 为什么我得到这个 : _cfurl: unrecognized selector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6301673/

相关文章:

iphone - 为 iPhone 的 UIButton 添加特定的触摸事件

ios - 保护随 iPhone 应用程序分发的数据

ios pjsip - 在 sip 通话期间播放声音

macos - AudioFileReadPackets错误-50

iOS - AudioServicesPlayAlertSound 在 ipod 上不工作?

ios - 如何确定HKQuantitySample数量类型?

ios - Objective C setFrame 不适用于 UIView

objective-c - 项目未使用 Objective-c for iOS 中的 round_page 进行编译

c# - 如何在 Xamarian iOS 应用程序中单击按钮 X 秒后触发事件?

ios - Extjs 输入被 ipad 虚拟键盘隐藏在焦点上