最近,我将我的 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-推荐答案 strong>
尝试使用 Instruments 工具来跟踪您将消息传递给已释放实例的位置。苹果有good guide为此:
- Launch Instruments.
- In the profiling template selection dialog that appears, click Zombies.
- Choose your device and app from the target device and process lists.
- Click Choose to create a trace document.
- Click the Record button in the toolbar (or press Command-R) to begin recording.
- Use your app normally.
- 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.
- If you close the Zombie Messaged dialog, you can reopen it by clicking the flag.
- 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.
- Select the Zombie event (or any other event you want to investigate) in the detail pane.
- Press Command-3 to display a stack trace for the selected event in the extended detail area of the inspector.
- 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.
- Calls made by your app are colored black and preceded by a user code icon.
- Double-click a method in the stack trace to display its code in Instruments.
- 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/
|