When to use -retainCount?

前端 未结 11 1523
借酒劲吻你
借酒劲吻你 2020-11-21 06:49

I would like to know in what situation did you use -retainCount so far, and eventually the problems that can happen using it.

Thanks.

11条回答
  •  不要未来只要你来
    2020-11-21 07:09

    I do find retainCounts very useful when checked using 'Instruments'.

    Using the 'allocations' tool, make sure 'Record reference counts' is turned on and you can go into any object and see its retainCount history.

    By pairing allocs and releases you can get a good picture of what is going on and often solve those difficult cases where something is not being released.

    This has never let me down - including finding bugs in early beta releases of iOS.

提交回复
热议问题