I have these 3 classes:
@interface BaseViewController : UIViewController
@interface BaseWebViewController : BaseViewController
@interface SecondaryWebViewController : BaseViewController
In AppDelegate, I am setting the rootViewController to be BaseWebViewController which will never be de-alloced throughout the entire lifetime of the app. In BaseWebViewController, I am calling [super viewDidLoad] and [super dealloc] in their respective methods.
Throughout most of the app, the user will be navigating through the UIWebView found on BaseWebViewController. But on certain links, I need to push (and later, pop out of) SecondaryWebViewController.
My question is that since both BaseWebViewController and SecondaryWebViewController are subclassing the BaseViewController, I'm not sure what to do regarding calling [super viewDidLoad] and [super dealloc] in SecondaryWebViewController.
In SecondaryWebViewController, I had been calling those [super viewDidLoad] and [super dealloc], but I noticed it caused some problems especially with random crashes when calling [super dealloc]. Since BaseWebViewController must always be present throughout the entire lifetime of the app, I don't ever want dealloc called on the BaseViewController.
Sorry, if this sounds confusing, but essentially, the flow looks like this:
- AppDelegate sets rootViewController to BaseWebViewController
- BaseWebViewController's viewDidLoad also calls the superclass BaseViewController's viewDidLoad
- Majority of the lifetime of the app is spent in BaseWebViewController, but occassionally SecondaryWebViewController needs to be pushed
- SecondaryWebViewController's viewDidLoad and dealloc calls the superclass's viewDidLoad and dealloc causing strange behaviour.
Currently, if I comment out [super viewDidLoad] and [super dealloc] in SecondaryWebViewController so that BaseViewController is never dealloced, then everything runs fine. However, I don't know if this is the right way of doing things.
What is the approach of calling super functions in a subclass such as this scenario?