Hi!
I have a simple UIViewController derived class. Which shows a simple UIImageView. Now the problem is that when I load this view controller using [NSBundle loadNibNamed.. method and then try and access its view using
viewController.view the reference count of both controller and view go up by 29. Later on when I release this viewController, i still see a retain count of 5.
When I analyze my code in Instruments it shows a memory leak.
Any hints are welcome? As per instruments there is leak in line 2 and line 8 of the following code.
ABCViewController *aViewController = [[ABCViewController alloc] initWithNibName:STR_XIB_NAME_SCREEN_IPHONE bundle:nil];
UIView * currentView = aViewController.view;
[m_appWindow addSubview:currentView];
if (m_CurrentViewController != nil)
{
//m_CurrentViewController stores the reference to the currentViewController loadedby the application.
[m_CurrentViewController.view removeFromSuperview];
[m_CurrentViewController release];
}
m_CurrentViewController = aViewController;
[m_appWindow bringSubviewToFront:currentView];
[m_CurrentViewController retain];
[aViewController release];