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

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


        
4条回答
  •  天涯浪人
    2021-02-15 17:39

    Lets say we have a SpriteKit scene where you have a gesture recognizer and you set its delegate.

    Then you dealloc this scene and its recognizer from its controller.

    It would lead to crash if the delegate method was called in scene during this process.

提交回复
热议问题