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

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


        
4条回答
  •  不思量自难忘°
    2021-02-15 17:25

    If you hold the only reference to self.tableView, there's no need of setting the delegate to nil.

    The only situation where you have to set the delegate to nil, if is another class has your class as a delegate, because if your class is destroyed, that other class will look for your class to implement some methods, and your call won't be there.

提交回复
热议问题