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

标题: iOS 10 [CFString 发布] : message sent to deallocated instance [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:42
标题: iOS 10 [CFString 发布] : message sent to deallocated instance

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

更新:

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

相关代码如图所示:

UITableViewCell *cell;

HKLoadingModel * model = [self modelForTableView:tableView];
ShopServiceType type = model == self.carwashLoadingModel ? ShopServiceCarWash : ShopServiceCarwashWithHeart;
JTShop *shop = [model.datasource safetyObjectAtIndex:indexPath.section];
NSArray * serviceArray = [self filterShopServiceByType:type andArray:shop.shopServiceArray];
NSInteger serviceAmount = serviceArray.count;
NSInteger sectionAmount = 1 + serviceAmount + 1;

if(indexPath.row == 0)
{
    cell = [self tableView:tableView shopTitleCellAtIndexPath:indexPath];
}
else if (indexPath.row == sectionAmount - 1)
{
    cell = [self tableView:tableView shopNavigationCellAtIndexPath:indexPath];
}
else
{
    cell = [self tableView:tableView shopServiceCellAtIndexPath:indexPath andShopService:serviceArray];
}

return cell;



Best Answer-推荐答案


尝试使用 Instruments 工具来跟踪您将消息传递给已释放实例的位置。苹果有good guide为此:

  1. Launch Instruments.
  2. In the profiling template selection dialog that appears, click Zombies.
  3. Choose your device and app from the target device and process lists.
  4. Click Choose to create a trace document.
  5. Click the Record button in the toolbar (or press Command-R) to begin recording.
  6. Use your app normally.
  7. 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.
  8. If you close the Zombie Messaged dialog, you can reopen it by clicking the flag.
  9. 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.
  10. Select the Zombie event (or any other event you want to investigate) in the detail pane.
  11. Press Command-3 to display a stack trace for the selected event in the extended detail area of the inspector.
  12. 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.
  13. Calls made by your app are colored black and preceded by a user code icon.
  14. Double-click a method in the stack trace to display its code in Instruments.
  15. Click the Xcode button at the top of the detail pane to open the code in Xcode for editing.

就我而言,崩溃是由 FoundationExtension pod 版本 0.59 引起的。一旦我删除它,我就再也没有崩溃了。

关于iOS 10 [CFString 发布] : message sent to deallocated instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38144618/






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