简体   繁体   English

如何使用ARC调试保留计数?

[英]How to debug retain count using ARC?

I'm using ARC on my iPhone app and I'm trying to catch a bug that gives me the following output (with NSZombieEnabled, MallocStackLogging and guard malloc ): 我在iPhone应用程序上使用ARC,并且试图捕获一个错误,该错误为我提供了以下输出(使用NSZombieEnabled, MallocStackLogging and guard malloc ):

*** -[MyCustomClass retain]: message sent to deallocated instance 0x534e00

How can I track a retain count using ARC? 我怎么可以跟踪使用ARC保留计数? What do I do using LLDB console with the instance 0x534e00 (of course any other instance that will appear) in order to find the deallocated instance? 我如何使用instance 0x534e00 (当然还会出现其他实例)的LLDB控制台来查找已释放的实例?

For the record: I'm not using any retain anywhere in my code. 记录:我没有在代码的任何地方使用任何retain

Thank you! 谢谢!

It doesn't mean that YOU are explicitly writing [MyCustomClass retain] . 这并不意味着您正在明确编写[MyCustomClass retain] The system is doing that for you. 系统正在为您执行此操作。 You should use Zombies and Instruments and try to track the problem. 您应该使用“僵尸和仪器”并尝试跟踪问题。 At least you know that the problem is with MyCustomClass , which narrows things. 至少您知道问题出在MyCustomClass ,这使事情变得狭窄。

Your choices are: 1. Don't use ARC, or 2. Use ARC. 您的选择是:1.不使用ARC,或2.使用ARC。 But you can't do both. 但是你不能两者都做。 You can't use non-ARC retain functions while using ARC. 使用ARC时,不能使用非ARC保留功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM