gpt4 book ai didi

iphone - 修改 Storyboard 后 Objective-C 释放僵尸对象

转载 作者:行者123 更新时间:2023-11-29 03:41:50 26 4
gpt4 key购买 nike

我对 iOS 应用程序有一些迷恋。经过调查我发现问题是一些悬空指针。为了找到它的来源,我开始使用“Zombies”跟踪模板在模拟器 (iOS 6.1) 上分析代码。

测试场景非常简单:选择 table 上的某个项目,然后通过其名称调用适当的摇摆来移动到下一个 Controller ,然后按后退按钮。当“后退”动画完成时会出现粉碎。

这是表格形式的探查器,其中包含已释放僵尸对象的数据(我删除了无趣的列,例如:#;类别 - 始终等于 CALayer;时间戳):

Event Type  RefCt   Size    Responsible Library Responsible Caller
Malloc 1 48 UIKit -[UIView _createLayerWithFrame:]
Retain 3 0 QuartzCore CA::Layer::insert_sublayer(CA::Transaction*, CALayer*, unsigned long)
Release 2 0 UIKit -[UIView(Internal) _addSubview:positioned:relativeTo:]
Retain 3 0 QuartzCore -[CALayerArray mutableCopyWithZone:]
Release 2 0 UIKit -[UIView(Hierarchy) bringSubviewToFront:]
Retain 3 0 QuartzCore -[CALayerArray copyWithZone:]
Release 2 0 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
Retain 3 0 QuartzCore -[CALayerArray copyWithZone:]
Release 2 0 UIKit -[UIView(Internal) _didMoveFromWindow:toWindow:]
Retain 2 0 QuartzCore -[CALayerArray copyWithZone:]
Release 1 0 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
Retain 3 0 QuartzCore -[CALayerArray copyWithZone:]
Release 2 0 UIKit -[UIView(Internal) _didMoveFromWindow:toWindow:]
Retain 3 0 QuartzCore -[CALayerArray copyWithZone:]
Release 2 0 UIKit -[UIView dealloc]
Release 1 0 UIKit -[UIView dealloc]
Zombie -1 0 QuartzCore CA::release_objects(X::List<void const*>*)

现在这个表没有指向我的代码的任何地方,所有条目都与系统库相关:UIKit 或 QuartzCore。所以我无法显示我的代码,因为我不知道哪一部分是错误的,而且有很多错误。

当我尝试查看更改历史记录时,第一次提交此问题时唯一显着的更改是在 Storyboard 中进行的更改。这很奇怪,因为 Storyboard的更改不应该出现此类问题。我不能说到底改变了什么( Storyboard XML 很难阅读)。

有什么建议可以让我找到/解决这个问题吗?或者也许有人有类似的问题?

最佳答案

我非常怀疑:

Release     2       0       UIKit               -[UIView dealloc]
Release 1 0 UIKit -[UIView dealloc]

这些调用的调用堆栈是什么?

过去,我曾遇到过由于在 -dealloc 中不正确地释放属性而导致的问题。为了确定起见,我在 -dealloc 中释放指针后将其密封。

[_prop release]; _prop = nil;

关于iphone - 修改 Storyboard 后 Objective-C 释放僵尸对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18312053/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com