简体   繁体   English

Objective-C如何检查哪些对象引用了我的对象(保留周期)

[英]Objective-C How to check which objects are referencing my object (retain cycle)

In a certain portion of code - I am expecting an object to be dellocated but it isn't. 在代码的特定部分中-我期望一个对象被分配,但事实并非如此。

Given that object - how can I check which objects are referencing it? 给定该对象-如何检查引用该对象的对象?

Also - Is it possible to know every time an objects reference count goes up? 另外-是否有可能每次对象引用计数增加时都知道? (and by which object) (以及哪个对象)

You cant check it. 你不能检查它。 Rather you should use instruments to check the same. 相反,您应该使用仪器进行检查。 They will show the retain count of the object. 它们将显示对象的保留计数。 Perform the steps by running the app on instrument and check for retain count. 通过在乐器上运行该应用程序并检查保留计数来执行这些步骤。

Even you should not use retainCount method to check. 即使您不应该使用keepCount方法进行检查。 There is no way to identify that which objects are pointing to you object. 无法识别哪个对象指向您的对象。

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

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