为什么我会收到此警告/错误?

发布于 2024-12-03 13:25:34 字数 570 浏览 3 评论 0原文

我已经放置了一些将字符串转换为数据的代码,然后将数据放入另一个文本字段中。一切正常,但是当我运行程序并点击包含此代码的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

愿与i 2024-12-10 13:25:34

根据调试器,您的 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.

吃素的狼 2024-12-10 13:25:34

听起来 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).

高跟鞋的旋律 2024-12-10 13:25:34

假设您的 InputData 必须是 UITextField,请尝试以下操作:

[InputData setText:OutputString];

Assuming your InputData must be UITextField, try this:

[InputData setText:OutputString];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文