#define TT_RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }
Why is does three20 consider it safe to assign an ivar to nil after releasing it? Is it unsafe to leave out the ivar = nil step?
This is all I found:
http://github.com/facebook/three20/commit/1b946f475fb28d60e0aafc9ef394050c642c3a5b#commitcomment-115517
I don’t think I’m using KVO/KVC, but I’m not really sure. I’m reading up on it now.
Thanks!
Matt
When inside
-dealloc, this question splits the Objective-C gurus. read this recent blog entry for example.When inside an implementation of other methods, my personal opinion is that you shouldn’t keep the variable in scope after the release in the first place. This code
might accidentally access
someObjectlater in code, thus leading to a crash. So you might saywould be better, because messaging to
nilis harmless.However, in this case you can remove the danger altogether:
Here I’m using a
{...}block to limit a scope of a variable. Then the use ofsomeObjectlater is simply a compile-time error.