I have the following property
.h
@property (nonatomic, strong) NSMutableDictionary *cache;
.m
@synthesize cache = _cach
You can add:
-(void)dealloc {
// If you are using ARC remove the line below
[super dealloc]
}
And put a breakpoint and it will tell you when it is being released. The dealloc method will be called with ARC as well, just be sure that you don't call [super dealloc] in ARC.
Can not answer for ARC, but viewdidUnload does not mean the VC is released. It means the view is being released. To force it, you can try having a NavigationController, push a couple of views, and in Simulator send some Memory Warnings. viewDidUnload will be called for the vcs that are not the top one.
Re: ARC, you can surely have a dealloc method, that will be called when the vc is released. Simply don't call super.
Regardless of whether you are using ARC or not, they will not be cleaned up in -viewDidUnload
. You have to explicitly release them (or set them to nil
under ARC.)
The short answer is NO. Instance variables will not be automatically released. It does not cause a dealloc on the view controller. The view being controlled is cleared.
Anything you want cleared, must be done explicitly in viewDidUnload (note that variables added via IB will be automatically placed in that method).
The typical scenario for viewDidUnload is that a view managed by a controller is no longer on the screen (e.g., another controller has pushed with navigation controller). The system has detected memory pressure, and your view has been unloaded.
Any weak references to objects in your view will be automatically cleared (as long as you don't have extra strong references to them somewhere). In viewDidUnload, you need to nil strong references to data that can be reloaded when the view is represented on screen.
Executing viewDidUnload is NOT the same as dealloc. If you are managing resources that must be released (or registered with KVO or Notification Center) you will need to do that work as well. Note, in these cases you will have to do them both in viewDidUnload and in dealloc (as appropriate).