Search code examples
iosobjective-cappdelegatestrong-typing

Controller in Appdelegate is never released


I have a strong reference in my AppDelegate and when I pop controller it isn't being released.

 @property (nonatomic, strong) MenuViewController        *menuViewController;

This controller is not being decollated at all because I nslog dealloc and it isn't appearing. Is there a way around this without putting this property somewhere else? I am assuming because Appdelegate is a singleton and all the properties stay alive throughout app life cycle.


Solution

  • I'm not sure how you're using this reference, but you can make it a weak pointer:

    @property (nonatomic, weak) MenuViewController *menuViewController;
    

    Set the pointer after you have initialized and presented the menuViewController.

    If you have to initialize the menuViewController first and keep a reference for a later use, then you should set self.menuViewController = nil when you don't need it anymore.