使用MD5算法时出错

发布于 2024-09-13 01:30:59 字数 1496 浏览 7 评论 0原文

我正在尝试运行这个 MD5 算法,这是我在 stackoverflow 上的这篇文章。但我不断收到以下错误:

2010-08-06 14:45:40.971 Intel[3195:a0f] -[TaskController md5:]: unrecognized selector sent to instance 0x108df0
2010-08-06 14:45:40.973 Intel[3195:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TaskController md5:]: unrecognized selector sent to instance 0x108df0'
*** Call stack at first throw:
(
0   CoreFoundation                      0x9875abba __raiseError + 410
1   libobjc.A.dylib                     0x96a3a509 objc_exception_throw + 56
2   CoreFoundation                      0x987a78db -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x987017e6 ___forwarding___ + 950
4   CoreFoundation                      0x987013b2 _CF_forwarding_prep_0 + 50
5   Intel                               0x00003143 -[TaskController findFileOrCreateFile] + 709
6   Intel                               0x00002d29 -[TaskController init] + 92
7   Intel                               0x00002c03 main + 128
8   Intel                               0x00002a6a start + 54
)

我虽然这可能与我的字符串是 UTF-8 有关,但我尝试输入以下字符串,但仍然收到错误:

NSString *foo = @"your text here";
const char *bar = [foo UTF8String];

有帮助吗?

非常感谢

I'm trying to run this MD5 algorithm, which I found on this post on stackoverflow . But I keep on getting the following error:

2010-08-06 14:45:40.971 Intel[3195:a0f] -[TaskController md5:]: unrecognized selector sent to instance 0x108df0
2010-08-06 14:45:40.973 Intel[3195:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TaskController md5:]: unrecognized selector sent to instance 0x108df0'
*** Call stack at first throw:
(
0   CoreFoundation                      0x9875abba __raiseError + 410
1   libobjc.A.dylib                     0x96a3a509 objc_exception_throw + 56
2   CoreFoundation                      0x987a78db -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x987017e6 ___forwarding___ + 950
4   CoreFoundation                      0x987013b2 _CF_forwarding_prep_0 + 50
5   Intel                               0x00003143 -[TaskController findFileOrCreateFile] + 709
6   Intel                               0x00002d29 -[TaskController init] + 92
7   Intel                               0x00002c03 main + 128
8   Intel                               0x00002a6a start + 54
)

I though it might have something to do with my string being UTF-8, but I have tried inputting the following string and still get errors:

NSString *foo = @"your text here";
const char *bar = [foo UTF8String];

Any help?

Thanks so much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

高速公鹿 2024-09-20 01:30:59

它与你的字符串格式没有任何关系。运行时正在寻找您的 md5 方法,但没有找到。您是否在 TaskController 对象的 @interface 部分中定义了它?您是否使用正确数量的参数定义/调用它?

It doesn't have anything to do with your string format. The runtime is looking for your md5 method and not finding it. Did you define it in your @interface section of your TaskController object? Did you define/call it with the right number of parameters?

宛菡 2024-09-20 01:30:59

读取异常信息:

-[TaskController md5:]:无法识别的选择器发送到实例 0x108df0

您尝试向无法识别此类消息的实例发送 md5: 消息。

<前><代码>5 英特尔 0x00003143 -[TaskController findFileOrCreateFile] + 709

这就是您尝试发送它的地方。

正如您在对 Wade Williams 的回答的评论中透露的那样,问题的原因是您已将该方法声明并定义为类方法 (+[TaskController md5:])。请注意您的声明如何在异常显示 - 的情况下有一个 +;问题是不匹配。

由于您将消息发送到 TaskController 实例,而不是 TaskController 类,因此解决方案过去和现在都是将声明更改为实例方法(-[TaskController md5:],如异常消息所述) 。另一种解决方案是将其保留为类方法,并更改消息表达式以将消息发送到类而不是实例 (hash = [TaskController md5:str])。

Read the exception message:

-[TaskController md5:]: unrecognized selector sent to instance 0x108df0

You tried to send an md5: message to an instance that does not recognize such messages.

5   Intel                               0x00003143 -[TaskController findFileOrCreateFile] + 709

And this is where you tried to send it from.

As you revealed in your comment on Wade Williams's answer, the cause of your problem was that you had declared and defined the method as a class method (+[TaskController md5:]). Note how your declaration had a + where the exception shows a -; the problem is the mismatch.

Since you were sending the message to a TaskController instance, not the TaskController class, the solution was and is to change the declaration to an instance method (-[TaskController md5:], like the exception message says). The other solution would have been to leave it as a class method and change the message expression to send the message to the class rather than an instance (hash = [TaskController md5:str]).

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