菜鸟教程小白 发表于 2022-12-11 20:35:24

objective-c - 我如何找出消息是从哪里发送的?


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

<p>控制台中的错误是:</p>

<pre><code>-: message sent to deallocated instance 0x11afab80
</code></pre>

<p>堆栈跟踪是:</p>

<pre><code> 0 CoreFoundation ___forwarding___
1 CoreFoundation _CF_forwarding_prep_0
2 UIKit -
3 UIAccessibility -
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 /main.m:14
17 MyApp Functional Tests start
</code></pre>

<p>...但我的代码中没有这些。我如何知道消息是从哪里发送的?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>使用命令:</p>

<p>Shell malloc_history process_id 内存</p>

<p>例如。 Shell malloc_history process_id 0x11afab80</p>

<p>启用相同的关注
1)MallocstackLogging
2) NsDebugEnabled
3)NSZombieEnabled</p>

<p>这样就可以解决问题了</p></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - 我如何找出消息是从哪里发送的?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/8256229/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/8256229/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - 我如何找出消息是从哪里发送的?