Sometimes I need to find out if an object will really be released. I could use Instruments of course, but that takes much time, and I have to search into millions of objects, so I used to do this:
-(void)release {
NSLog(@"I'm released");
[super release];
}
But the problem is: is this safe to do? Can I get any problems when I override -(void)release. Also, is it really void? And what if I build my application for distribution, but per accident leave it there? Or is it just safe? Thanks
It’s fine, but please restrict it for debugging only.
It’s not
void, butoneway void.Note that if you only override this for NSObject, then the
-releasemessages sent to “toll-free bridged containers” (e.g. NSCFArray, etc.) will be missed since they’ve also overridden-releaseto forward toCFRelease.