【发布时间】:2012-11-14 19:48:37
【问题描述】:
我在我的 iPhone 应用程序上使用了 ARC,我试图捕捉一个错误,它给我以下输出(NSZombieEnabled, MallocStackLogging and guard malloc):
*** -[MyCustomClass retain]: message sent to deallocated instance 0x534e00
如何使用 ARC 跟踪保留计数?我应该如何使用带有instance 0x534e00 的 LLDB 控制台(当然会出现任何其他实例)来找到释放的实例?
郑重声明:我的代码中没有使用任何retain。
谢谢!
【问题讨论】:
-
使用 Instrument 的“僵尸”工具?
-
如果您使用 ARC,为什么会向您的自定义类发送保留消息?但是,您应该使用 __strong 限定符将其更改为强引用。
-
我没有使用retain,但是很强大。这就是我被这条消息绊倒的原因。
-
在使用 ARC 时不要使用显式调用。使用 ARC 时不能调用保留、复制、可变复制、自动释放或释放。因此,删除语句 [MyCustomClass retain]。
-
查看本教程以了解如何使用 Zombies 仪器:markj.net/iphone-memory-debug-nszombie
标签: iphone objective-c ios cocoa-touch automatic-ref-counting