简体   繁体   English

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

[英]Why am I getting this: _cfurl: unrecognized selector

My init starts like this:我的初始化是这样开始的:

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

When we get to that last line, it throws this:当我们到达最后一行时,它会抛出这个:

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'

Yeah, it's a bit uncompact for debugging.是的,调试起来有点不紧凑。

Just before I get the dump, theFirstNoise contains the expected (sort of) data.就在我得到转储之前,theFirstNoise 包含预期的(某种)数据。 (It's description method prints a weird form, but I am informed that's normal.) (它的描述方法打印出一个奇怪的形式,但我被告知这是正常的。)

Off the top of my head, it looks like theFirstNoise is actually an NSPathStore2 (a private subclass of NSString ) instead of an NSURL .在我的脑海中,看起来theFirstNoise实际上是NSPathStore2NSString的私有子类)而不是NSURL

Edit: NSPathStore2 objects will contain file paths.编辑: NSPathStore2对象将包含文件路径。 If you need to turn these into NSURL s, you can simply pass them to +[NSURL fileURLWithPath:] .如果您需要将这些转换为NSURL ,您可以简单地将它们传递给+[NSURL fileURLWithPath:]

This line:这一行:

NSURL *theFirstNoise = [[sounds allKeys] objectAtIndex:0];

is the problem: [sounds allKeys] returns an NSArray of keys, and objectAtIndex: therefore is returning an NSString, and not the URL.是问题所在: [sounds allKeys] 返回键的 NSArray,而 objectAtIndex: 因此返回的是 NSString,而不是 URL。 I wish the compiler would have been a little more helpful.我希望编译器会更有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会出现“无法识别的选择器”错误? - Why am I getting “unrecognized selector” errors? 选择器语法:为什么我得到无法识别的选择器错误? - selector syntax: why I am getting unrecognized selector error? 为什么我得到一个“无法识别的选择器发送到实例”错误? - Why am I getting a `unrecognized selector sent to instance` error? 为什么我会收到“ [__NSArrayI allKeys]:无法识别的选择器发送到实例” /为什么要进行NSDictionary转换? - Why am I getting “[__NSArrayI allKeys]: unrecognized selector sent to instance” / why is NSDictionary transforming? 为什么我的MapViewController收到无法识别的选择器发送到实例异常? (iOS) - Why am I getting a unrecognized selector sent to instance exception with my MapViewController? (iOS) 为什么我收到此错误? CCSprite copyWithZone无法识别的选择器发送到实例 - Why am I getting this error? CCSprite copyWithZone unrecognized selector sent to instance 当从Google Data Objective-C客户端库中继承GDataEntryBase时,为什么会出现“无法识别的选择器”错误? - Why am I getting “unrecognized selector” errors when subclassing GDataEntryBase from Google Data Objective-C Client Library? 为什么得到“由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[UIImageView _isResizable]:无法识别的选择器” - Why an I getting “Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView _isResizable]: unrecognized selector” 为什么在NSTimer选择器中得到EXC_BAD_ACCESS? - Why am I getting a EXC_BAD_ACCESS in a NSTimer selector? 正在-[CFURL保留]崩溃? - Getting -[CFURL retain] crash?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM