菜鸟教程小白 发表于 2022-12-12 11:42:38

iOS 10 [CFString 发布] : message sent to deallocated instance


                                            <p><p>最近,我将我的 iPhone 升级到了 iOS 10。我在 iPhone 上安装了我的应用程序后,我发现当我在我的应用程序中点击一个 tableView 时,它肯定会崩溃。我在方法 <code>cellForRowAtIndexPath</code> 中设置了一些断点,并在 Diagnostics 表中选择了 Zombie Objects。但是消息 <code>: message sent to deallocated instance 0x17063b960</code> 总是出现在 Debug 区域。此问题仅出现在 iOS 10 Beta 上,我不确定是否是 iOS 10 Beta 引起的问题。有没有人和我一样遇到过这个问题?我将不胜感激。</p>

<p><strong>更新:</strong></p>

<p>返回<code>cell</code>时,会出现crash:<code>Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)</code> 和<code>Thread 1: signal SIGKILL </code></p>

<p>相关代码如图所示:</p>

<p>UITableViewCell *cell;</p>

<pre><code>HKLoadingModel * model = ;
ShopServiceType type = model == self.carwashLoadingModel ? ShopServiceCarWash : ShopServiceCarwashWithHeart;
JTShop *shop = ;
NSArray * serviceArray = ;
NSInteger serviceAmount = serviceArray.count;
NSInteger sectionAmount = 1 + serviceAmount + 1;

if(indexPath.row == 0)
{
    cell = ;
}
else if (indexPath.row == sectionAmount - 1)
{
    cell = ;
}
else
{
    cell = ;
}

return cell;
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>尝试使用 Instruments 工具来跟踪您将消息传递给已释放实例的位置。苹果有<a href="https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/EradicatingZombies.html" rel="noreferrer noopener nofollow">good guide</a>为此:</p>

<blockquote>
<ol>
<li>Launch Instruments.</li>
<li>In the profiling template selection dialog that appears, click Zombies.</li>
<li>Choose your device and app from the target device and process lists.</li>
<li>Click Choose to create a trace document.</li>
<li>Click the Record button in the toolbar (or press Command-R) to begin recording.</li>
<li>Use your app normally.</li>
<li>If a call is made to a deallocated object, a flag is inserted in the timeline pane and a Zombie Messaged dialog appears, indicating
that a message was sent to a deallocated object at a specific memory
address.</li>
<li>If you close the Zombie Messaged dialog, you can reopen it by clicking the flag.</li>
<li>Click the focus arrow next to the zombie’s memory
address to display the memory history of the zombie object in the
detail pane, along with corresponding reference counts and method
calls.</li>
<li>Select the Zombie event (or any other event you want to investigate) in the detail pane.</li>
<li>Press Command-3 to display a stack trace for the selected event in the extended detail area of the inspector.</li>
<li>Click the Collapse button in the extended detail
area to hide system calls in the stack trace. This makes it easier to
locate your app’s methods.</li>
<li>Calls made by your app are colored black and preceded by a user code icon.</li>
<li>Double-click a method in the stack trace to display its code in Instruments.</li>
<li>Click the Xcode button at the top of the detail pane to open the code in Xcode for editing.</li>
</ol>
</blockquote>

<p>就我而言,崩溃是由 <code>FoundationExtension</code> pod 版本 0.59 引起的。一旦我删除它,我就再也没有崩溃了。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS 10 : message sent to deallocated instance,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38144618/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38144618/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS 10 [CFString 发布] : message sent to deallocated instance