简体   繁体   English

NSInvalidArgumentException ...为什么?

[英]NSInvalidArgumentException…why?

I have this code, where self.currentSet.imagesPrefix is a NSString and also [attributeDict objectForKey@"imagesPrefix"] is a NSSTring 我有这段代码,其中self.currentSet.imagesPrefix是NSString,并且[attributeDict objectForKey @“ imagesPrefix”]是NSSTring

self.currentSet.imagesPrefix=[attributeDict objectForKey:@"imagesPrefix"];

but in console I have this problem: 但是在控制台中,我有这个问题:

2011-11-15 16:04:08.850 MyApp[8579:707] -[__NSCFString setImagesPrefix:]: unrecognized selector sent to instance 0x168600
2011-11-15 16:04:08.857 MyApp[8579:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setImagesPrefix:]: unrecognized selector sent to instance 0x168600'

我的猜测是您尚未合成imagesPrefix来生成setImagesPrefix方法。

This means that self.currentSet is not the object you think it is. 这意味着self.currentSet不是您认为的对象。 Instead of chaining the properties, pull it apart into separate stages so you can debug: 无需链接属性,而是将其拉到单独的阶段,以便可以调试:

id firstpart = self.currentSet;
NSLog(@"%@", firstpart);

This will reveal what self.currentSet really is. 这将揭示出self.currentSet实际上是什么。 Prepare for a surprise. 准备一个惊喜。 Then the real debugging can begin, because you'll have to figure out why it isn't what you think it is. 然后就可以开始真正的调试,因为您必须弄清楚为什么它不是您认为的那样。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM