In dealloc method set any delegate to nil is needed or not needed

后端 未结 3 1184
花落未央
花落未央 2020-12-22 03:42

I have created tableview in my view by programmatic like below

table = [[UITableView alloc] initWithFrame:CGRectMake(0, 44, 320, 370) style:UITableViewCel         


        
3条回答
  •  萌比男神i
    2020-12-22 04:02

    To add to the answers above, you do not need

    table = nil;
    

    in your dealloc. It won't hurt, but it is not necessary to nil out your ivars. Your view is being dealloc'ed and therefore your ivars will no longer be accessible. You are probably confusing that with:

    self.table = nil;
    

    which can function as an alternative way to release if you are accessing the ivar via a property.

    Of course if you have ARC turned on, then you don't need the release at all.

    And to answer your actual question, if you don't nil out the table's delegate and datasource on the dealloc of the view....nothing will happen. They are set to the view, which is in the process of being released. In this case, you will have no issues not doing it. In theory it's good form.

提交回复
热议问题