iPhone: Calling dealloc on parentViewController causes an exception

Posted by arielcamus on Stack Overflow See other posts from Stack Overflow or by arielcamus
Published on 2010-03-03T10:36:32Z Indexed on 2010/12/27 2:53 UTC
Read the original article Hit count: 261

Hi,

I'm dealing with viewDidUnload and dealloc methods and I've founded a problem when calling [super dealloc]; in parent view controller.

I have a lot of view controllers with custom code which I have putted outside on a parent view controller. So, when defining my view controllers I set a reference to the super class:

@interface LoginViewController : AbstractViewController

Then, at the dealloc method I call the AbstractViewController dealloc method:

//(Login View Controller code)
- (void)dealloc {
    [user release];
    [passwd release];
    [super dealloc];
}

[super dealloc] execute the following code:

//(Abstract View Controller code)
- (void)dealloc {
    [dbUtils release];
    [loadingView release];
    [super dealloc];
}

If I simulate a memory warning on iPhone Simulator, the following exception is thrown:

2010-03-03 11:27:45.805 MyApp[71563:40b] Received simulated memory warning.
2010-03-03 11:27:45.808 MyApp[71563:40b] *** -[LoginViewController isViewLoaded]:     message sent to deallocated instance 0x13b51b0
kill
quit

However, if I comment the [super dealloc] line in AbstractViewController the exception is not thrown and my app still running.

Thank you for your help once again!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about dealloc