Reputation: 185
If I have a custom view controller class that I want to reuse but when used in one instance has a retained property that isn't actually used during the view's lifecycle, do I need to release it in dealloc?
Upvotes: 0
Views: 607
Reputation: 1199
You should release any objects that you alloc or retain in dealloc.
If it's referenced in interface builder, you'll also want to release and set to nil in the viewDidUnload() of your view controller as well as releasing in your dealloc.
Upvotes: 2
Reputation: 86691
It's OK to send messages to nil, so you should just release your retain properties in dealloc no matter what. If the property hasn't been used, it will be nil and sending release to it is effectively a no-op.
Upvotes: 0
Reputation: 15588
You don't need to call release on a retained property. The setter method is implemented such that giving it a null value will release it for you. In your dealloc method just set it to nil:
self.someProperty = nil;
Upvotes: 0