Why do we set delegate to nil at dealloc if the object is going to be destroyed anyway?

后端 未结 4 1110
死守一世寂寞
死守一世寂寞 2021-02-15 17:18
-(void) scrollViewDidScroll:(UIScrollView *)scrollView
{
    PO(NSStringFromCGPoint(self.tableView.contentOffset));
    PO(NSStringFromUIEdgeInsets(self.tableView.conten         


        
4条回答
  •  死守一世寂寞
    2021-02-15 17:47

    Actually this is not required. We are doing this to avoid forming retain cycle. We should not create a delegate with strong reference. If you accidentally created a delegate with strong reference then both parent and child will not get released. In that case dealloc itself will not get called. So it s not necessary.

提交回复
热议问题