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

标签 objective-c cocoa stack-trace message-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 ()
...

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

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

最佳答案

转发内容用于呃... 转发消息。每个对象都可以轻松地将它收到的消息转发给其他一些对象,参见优秀的 tutorial by Scott Stevenson .当您的 GameObject 收到一条它不理解的消息时,它会尝试转发它。如果没有实现转发,则会调用 doesNotRecognizeSelector 方法,您会得到异常。

详细说明可以在 Apple documentation 中找到对于 NSObject 类:

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.

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

关于objective-c - 堆栈跟踪中的 __forwarding__ 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1493580/

相关文章:

c++ - 如何使用 `boost::stacktrace` 使 `fmt::format` 格式化

iphone - FBConnect 演示应用程序

objective-c - NSTextfield + NSMenu 和第一响应者

macos - 如何使用多个不同的窗口启动基于 Cocoa 文档的应用程序?

java - dumpstack() 和 printStackTrace() 之间的区别

Java - 循环堆栈跟踪并获取类和方法实例?

ios - 显示 UITableView 的本地化字母索引

ios - 在 plist 文件上实现 2 个 ATS 规范

objective-c - 是否存在用于通过相机检测形状的任何类型的 iOS API?

objective-c - 定义常量并将其作为参数传递导致 "discards qualifier from pointer target type"