John smith John smith - 9 months ago 90
Objective-C Question

Dealloc on UIViewController

Everything is in the title.
I would like to know when the dealloc method is called on UIViewController using ARC ?

In my app I have a navigation controller with multiple view controllers. When I dismiss my main navigation controller, the dealloc method is not getting call in any of my controllers ..



Dealloc is called on a UIViewController when the memory for that viewController is going to be deallocated from memory. If the dealloc method is not being called on your viewControllers when you expect it to be, you probably have a memory leak. It sounds like your view controllers may be retaining strong references to each other.

@property (nonatomic) UIViewController *otherController;

Change one side of the relationship to

@property (nonatomic, weak) UIViewController *otherController;