执行以下代码行时,我创建的应用程序崩溃了 其中 c1 是整数变量。
NSString *path = c1.stringValue;
在日志中显示以下错误:
-[NSCFString stringValue]: unrecognized selector sent to instance 0x5566e80 2011-05-11 14:56:15.813 e-TREND[1552:207] Uncaught Exception happens!! (NSInvalidArgumentException: -[NSCFString stringValue]: unrecognized selector sent to instance 0x5566e80) 2011-05-11 14:56:15.816 e-TREND[1552:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString stringValue]: unrecognized selector sent to instance 0x5566e80'
如果有人有任何想法解决此问题,请相应回答。
最佳答案
where c1 is an integer variable
这是什么意思? c1是如何声明的?
如果 c1
是 int
,那么 c1.stringValue
甚至无法编译。
点语法仅在对象引用 - c1
- 属于特定对象引用类型(不是 id
)且该引用 - 该类 - 时才有效。 - 响应该方法。
所以,你有这样的东西:
MyThingThatRespondsToStringValue *c1;
然后您在某个地方将 NSString
的实例分配给该变量,这导致了崩溃。
关于iphone - [NSCFString 字符串值] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5959918/