为什么我会收到此警告/错误?
我已经放置了一些将字符串转换为数据的代码,然后将数据放入另一个文本字段中。一切正常,但是当我运行程序并点击包含此代码的 IB 操作按钮时:
[InputData setStringValue:OutputString];
我收到此错误:
线程 1:程序收到信号:“SIGABRT”。
在输出中在 Xcode 底部的区域中,我收到此消息:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSConcreteMutableData” setStringValue:]: 无法识别的选择器发送到实例 0x62507e0'
为什么会发生这种情况? 警告告诉我:
实例方法 -setStringValue' 未找到(返回类型默认为 id)
发生了什么事,我已经查看过它,看起来它应该可以工作。我做错了什么?我只是 Objective-C 的初学者。
谢谢,任何事情都值得赞赏。
I have placed together some code which converts strings into data, and then places the data into another textfield. Everything works fine, but when I run the program and tap the button with the IB Action that contains this code:
[InputData setStringValue:OutputString];
I get this error:
Thread 1: Program Received Signal: "SIGABRT".
And in the Output area in the bottom of Xcode I get this message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData setStringValue:]: unrecognized selector sent to instance 0x62507e0'
Why does this happen?
The warning tells me that:
Instance method -setStringValue' not found (return type defaults to id)
What is going on, I have looked over it and it seems like it should work. What am I doing wrong? Im only a beginner with Objective-C.
Thank you, anything is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据调试器,您的 InputData 对象是 NSMutableData 的实例,它没有 setStringValue 方法。查看您的代码并确认您正在调用您真正想要定位的对象上的方法。
According to the debugger your InputData object is an instance of NSMutableData, which does not have a setStringValue method. Look through your code and confirm that you're calling the method on the object you're really trying to target.
听起来 NSData 上有一个类别包含 setStringValue 方法。类别实现文件的名称可能类似于 NSData-extras.m。确保该文件已添加到 Xcode(如果 Xcode 已知,则该文件是正在构建的目标的一部分)。
Sounds like there is a category on NSData that includes a setStringValue method. The category implementation file is likely named something like NSData-extras.m. Ensure that file has been added to Xcode (and if already known to Xcode, is part of the Target being built).
假设您的 InputData 必须是 UITextField,请尝试以下操作:
Assuming your InputData must be UITextField, try this: