I have a large hierarchy of view/viewcontrollers.
In the main controller I have the following code where aViewController is a member of MyClass:
@implementation MyClass
...
- (void) viewDidLoad
{
[self.view addSubview:aViewController_.view];
[aViewController_ setDataSource:self];
[aViewController_ setDelegate:self];
}
- (void)dealloc
{
//[aViewController_.view removeFromSuperview]; // All ok when this is added
[aViewController_ release];
[super dealloc];
}
...
@end
When running this, I see that aViewController
is never released - retain count remains 1 at the end.
If howeevr I add [aViewController_.view removeFromSuperview];
to dealloc the everything works fine.
Why is this? Shouldn't [super dealloc]
take care of the release of the view? Does it matter that the view is being released after the controller?
I have tried to reproduce with a simple test application without any luck.