我为什么得到这个:_cfurl:无法识别的选择器

|| 我的初始化是这样的:
- (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\'
是的,调试起来有点紧凑。 在我得到转储之前,FirstNoise包含了预期的(某种)数据。 (它的描述方法打印出一个奇怪的表格,但我被告知这是正常的。)     
已邀请:
        在我的头顶上,看起来
theFirstNoise
实际上是
NSPathStore2
(ѭ4private的私有子类)而不是
NSURL
。 编辑:
NSPathStore2
对象将包含文件路径。如果您需要将它们变成
NSURL
,只需将它们传递给
+[NSURL fileURLWithPath:]
。     
        这行:
NSURL *theFirstNoise = [[sounds allKeys] objectAtIndex:0];
问题是:[sounds allKeys]返回一个NSArray键,而objectAtIndex:因此返回一个NSString,而不是URL。我希望编译器会有所帮助。     

要回复问题请先登录注册