堆栈跟踪中的 __forwarding__ 是什么意思?

发布于 2024-08-06 18:05:10 字数 1301 浏览 1 评论 0原文

(gdb) bt
#0  0x302ac924 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ ()
#1  0x92077e3b in objc_exception_throw ()
#2  0x302d6ffb in -[NSObject doesNotRecognizeSelector:] ()
#3  0x3026e056 in ___forwarding___ ()
#4  0x3024a0a2 in __forwarding_prep_0___ ()
#5  0x00004ae9 in -[GameObject doesTouch:] (self=0xe893a0, _cmd=0x643ee, obj=0xe82e20) at /Users/aaa/Desktop/CPT/Game/Classes/GameObject.m:220
#6  0x00006e05 in -[StaticGrid checkTouchNearest:] (self=0xe82f20, _cmd=0x64ec3, obj=0xe893a0) at /Users/aaa/Desktop/CPT/Game/Classes/StaticGrid.m:62
#7  0x0000a393 in -[EAGLView touchesBegan:withEvent:] (self=0xe8dad0, _cmd=0x3199fa3c, touches=0x632c0b0, event=0xe14590) at /Users/aaa/Desktop/CPT/Game/Classes/EAGLView.m:459
#8  0x30910f33 in -[UIWindow _sendTouchesForEvent:] ()
#9  0x308faecb in -[UIApplication sendEvent:] ()
#10 0x309013e1 in _UIApplicationHandleEvent ()
#11 0x32046375 in PurpleEventCallback ()
#12 0x30245560 in CFRunLoopRunSpecific ()
#13 0x30244628 in CFRunLoopRunInMode ()
#14 0x32044c31 in GSEventRunModal ()
#15 0x32044cf6 in GSEventRun ()
#16 0x309021ee in UIApplicationMain ()
...

目前我遇到了一个罕见的错误,但我还不知道原因。我不知道该看哪里,所以我想问的是前五行(#0到#4)是什么意思?我知道它声称存在一些错误,但是“___forwarding___”之类的东西是什么?

如果您有这方面的知识,请帮忙。非常感谢。

(gdb) bt
#0  0x302ac924 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ ()
#1  0x92077e3b in objc_exception_throw ()
#2  0x302d6ffb in -[NSObject doesNotRecognizeSelector:] ()
#3  0x3026e056 in ___forwarding___ ()
#4  0x3024a0a2 in __forwarding_prep_0___ ()
#5  0x00004ae9 in -[GameObject doesTouch:] (self=0xe893a0, _cmd=0x643ee, obj=0xe82e20) at /Users/aaa/Desktop/CPT/Game/Classes/GameObject.m:220
#6  0x00006e05 in -[StaticGrid checkTouchNearest:] (self=0xe82f20, _cmd=0x64ec3, obj=0xe893a0) at /Users/aaa/Desktop/CPT/Game/Classes/StaticGrid.m:62
#7  0x0000a393 in -[EAGLView touchesBegan:withEvent:] (self=0xe8dad0, _cmd=0x3199fa3c, touches=0x632c0b0, event=0xe14590) at /Users/aaa/Desktop/CPT/Game/Classes/EAGLView.m:459
#8  0x30910f33 in -[UIWindow _sendTouchesForEvent:] ()
#9  0x308faecb in -[UIApplication sendEvent:] ()
#10 0x309013e1 in _UIApplicationHandleEvent ()
#11 0x32046375 in PurpleEventCallback ()
#12 0x30245560 in CFRunLoopRunSpecific ()
#13 0x30244628 in CFRunLoopRunInMode ()
#14 0x32044c31 in GSEventRunModal ()
#15 0x32044cf6 in GSEventRun ()
#16 0x309021ee in UIApplicationMain ()
...

Currently I have a rare occuring error that I do not know the cause yet. I am not sure where to look at, so what I want to ask is what do the first five lines (#0 to #4) mean? I know that it claims that there are some errors, but what are those things like "___forwarding___"?

If you have some knowledge in this, please help. Thank you very much.

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

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

发布评论

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

评论(2

夜未央樱花落 2024-08-13 18:05:10

转发内容用于呃…转发消息。每个对象都可以轻松地将其收到的消息转发给其他对象,请参阅 Scott Stevenson 的优秀教程。当您的 GameObject 收到它无法理解的消息时,它会尝试转发该消息。如果没有实现转发,则调用 doesNotRecognizeSelector 方法,并且您会收到异常。

详细说明可以在 NSObject 类的 Apple 文档

当一个对象被发送消息时
它没有相应的方法,
运行时系统给接收者
委托消息的机会
到另一个接收器。它委托
通过创建 NSIncation 来发送消息
代表消息的对象和
向接收者发送
转发调用:消息包含
这个 NSIncation 对象作为
争论。接收者的
forwardIncation: 方法可以然后
选择将消息转发至
另一个物体。
(……)
NSObject 的实现
前向调用:简单地调用
doesNotRecognizeSelector:方法;它
不转发任何消息。因此,如果
你选择不实施
转发调用:,发送
无法识别的对象消息将
引发异常。

至于您的错误,似乎 GameObject 收到了一些它不理解的消息。这可能是一个简单的拼写错误,也可能是一些更微妙的问题,例如内存管理错误,您必须向我们提供更多信息。

The forwarding stuff is used for uhm… forwarding messages. Each object can easily forward the messages it receives to some other objects, see the excellent tutorial by Scott Stevenson. When your GameObject receives a message it does not understand, it tries to forward it. If there is no forwarding implemented, the doesNotRecognizeSelector method is called and you get the exception.

Detailed description can be found in the Apple documentation for the NSObject class:

When an object is sent a message for
which it has no corresponding method,
the runtime system gives the receiver
an opportunity to delegate the message
to another receiver. It delegates the
message by creating an NSInvocation
object representing the message and
sending the receiver a
forwardInvocation: message containing
this NSInvocation object as the
argument. The receiver’s
forwardInvocation: method can then
choose to forward the message to
another object.
(…)
NSObject’s implementation of
forwardInvocation: simply invokes the
doesNotRecognizeSelector: method; it
doesn’t forward any messages. Thus, if
you choose not to implement
forwardInvocation:, sending
unrecognized messages to objects will
raise exceptions.

As for your error, it seems that the GameObject gets sent some message it does not understand. This can be a simple typo or something more subtle like memory management error, you’d have to give us more information.

傲鸠 2024-08-13 18:05:10

我要检查的第一件事是 GameObject 是否有 -doesTouch: 或 +doesTouch: 方法。我不确定 __forwarding... 是什么。您在控制台日志中看到什么错误消息?

First thing I would check is whether GameObject has a -doesTouch: or +doesTouch: method. I am not sure what __forwarding... is. What error message do you see in the console log?

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