I have a tableview(being IBOutlet) and tableviewController in my ViewController
what I do is
//.... allocation for tableviewController self.tableview.delegate = tableviewController;
//now t开发者_如何学编程his increases the retain count of tableviewController...
So in deallocation do I need to set the tableview delegate to nil...like
self.tableview.delegate = nil; or self.tableview = nil; // is sufficient to make sure that the retain count of tableviewController get decreased by 1.
The tableView already realeases its delegate in its dealloc method, so you should be ok without having to explicitly set the delegate to nil.
The table view does not retain its delegate:
@property(nonatomic, assign) id<UITableViewDelegate> delegate
The reason is that retaining would likely cause a retain cycle. See Avoiding retain cycles rule #3: "Connection" objects should not retain their target. To keep the delegate alive, you must maintain a reference to it yourself somewhere.
精彩评论