How can identify strong reference cycles in Swift?

前端 未结 5 2020
无人及你
无人及你 2021-01-30 07:09

Is there a tool or method to locate strong references cycles in my SWIFT code?

A strong reference cycle is when two instances of classes reference each other without

5条回答
  •  忘掉有多难
    2021-01-30 07:44

    very simple approach is to put a print in deinitialiser

    deinit {
       print(" destroyed.")
    }
    

    ensure that you are seeing this line getting printed on the console. put deinit in all your viewcontrollers. in case if you were not able to see for particular viewcontroller, means that their is a reference cycle.possible causes are delegate being strong, closures capturing the self,timers not invaidated,etc.

提交回复
热议问题