iosuitableviewpointersviewdidunload

iOS UIViewController,why "self" become to "wild pointer" in viewDidUnload?


my code snippet:

- (void)viewDidUnload{
    [super viewDidUnload];
    self.statusView = nil;
    self.tableView = nil;
    self.noDataView = nil;
}

In a rare situation, my app crashed in line self.noDataView = nil;. When I debug by po self, it seemed that it's pointing something other than current controller. What is possible reason?

PS:self.tableView's delegate and dataSource is set to self in init method. Does that have any relation to this?


Solution

  • First, [super viewDidUnload] should be used as the last statement. However, that won't fix your error, probably.

    The reason for your problem is quite simple. Your controller is overreleased somewhere. Do you have zombie detection enabled? The code where the application crashes is usually irrelevant because the problem happened earlier.