Reputation: 11231
I have a tableview(being IBOutlet) and tableviewController in my ViewController
what I do is
//.... allocation for tableviewController self.tableview.delegate = tableviewController;
//now this 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.
Upvotes: 0
Views: 315
Reputation: 19916
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.
Upvotes: 1
Reputation: 22405
The tableView already realeases its delegate in its dealloc method, so you should be ok without having to explicitly set the delegate to nil.
Upvotes: 1