iphone - [NSCFString 字符串值] : unrecognized selector sent to instance

标签 iphone objective-c

执行以下代码行时,我创建的应用程序崩溃了 其中 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是如何声明的?

如果 c1int,那么 c1.stringValue 甚至无法编译。

点语法仅在对象引用 - c1 - 属于特定对象引用类型(不是 id)且该引用 - 该类 - 时才有效。 - 响应该方法。

所以,你有这样的东西:

MyThingThatRespondsToStringValue *c1;

然后您在某个地方将 NSString 的实例分配给该变量,这导致了崩溃。

关于iphone - [NSCFString 字符串值] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5959918/

相关文章:

iphone - 任何关于如何添加 UITabBar 的基于 "non TabBar-template"的教程?

objective-c - NSString stringWithContentOfFile

iphone - 从月份名称获取月份编号?

ios - 关于 UIGestureRecognizer

iphone - iOS 7 上的 UILabel 自动调整大小错误

iphone - 如何从 iPhone 应用程序中的 UIWebView 链接跳转到 App Store?

ios - 应用程序无法连接到 iTunes Store

iphone - 使用后退按钮时 UISwitch 会切换到 OFF 状态

objective-c - Objective C 指针可以用来指向 swift 对象实例吗

ios - 字符串值在 Objective-C 中始终显示 nil