If I have a custom vie开发者_Python百科w 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?
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.
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.
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;
精彩评论