OGeek|极客世界-中国程序员成长平台

标题: objective-c - 我如何找出消息是从哪里发送的? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:35
标题: objective-c - 我如何找出消息是从哪里发送的?

我们的应用程序在测试期间崩溃,向已释放的 UINavigationItem 发送消息。我看过使用 Instruments,但所有的发布和保留看起来都很平衡;看起来有些东西卡在变量上而没有保留它。我想知道消息是从哪里发送的,这样我就可以确保该对象的存活时间足够长以接收它。

控制台中的错误是:

-[UINavigationItem safeValueForKey:]: message sent to deallocated instance 0x11afab80

堆栈跟踪是:

 0 CoreFoundation ___forwarding___
 1 CoreFoundation _CF_forwarding_prep_0
 2 UIKit -[UINavigationItemButtonViewAccessibility(SafeCategory) accessibilityTraits]
 3 UIAccessibility -[NSObject(NSObjectAccessibility) accessibilityAttributeValue:]
 4 UIAccessibility _copyAttributeValueCallback
 5 AXRuntime _AXXMIGCopyAttributeValue
 6 AXRuntime _XCopyAttributeValue
 7 AXRuntime mshMIGPerform
 8 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
 9 CoreFoundation __CFRunLoopDoSource1
10 CoreFoundation __CFRunLoopRun
11 CoreFoundation CFRunLoopRunSpecific
12 CoreFoundation CFRunLoopRunInMode
13 GraphicsServices GSEventRunModal
14 GraphicsServices GSEventRun
15 UIKit UIApplicationMain
16 MyApp Functional Tests main [myapp]/main.m:14
17 MyApp Functional Tests start

...但我的代码中没有这些。我如何知道消息是从哪里发送的?



Best Answer-推荐答案


使用命令:

Shell malloc_history process_id 内存

例如。 Shell malloc_history process_id 0x11afab80

启用相同的关注 1)MallocstackLogging 2) NsDebugEnabled 3)NSZombieEnabled

这样就可以解决问题了

关于objective-c - 我如何找出消息是从哪里发送的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8256229/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4