So I am creating an class that does an animation. There is a timer delay. So I will instantiate this class. Have it do its thing then have a timerFinished type of delegate to continue on.
This question comes from my sheltered garbage collection career.
What is the best way to release this object?
Do I have it release itself when it finishes that task (not even sure that this is possible).
Do I have the object that implements the delegate release it?
Having trouble wrapping my mind around the best way to do this.
FWIW, I’ve found it rather dangerous to have objects that retain/release themselves, for the simple reason that you may have objects hanging around in the background that you don’t know about anymore. Even worse, if they message another object, they may be retaining views or controllers you’ve long closed.
Also, this pattern doesn’t work in the garbage collector on MacOS.
So, I’m currently trying to re-educate myself to keep a global NSArray for each class that may have such objects floating around. That way, during debugging I have a place where I can easily see these objects, and I can cancel them from dealloc by e.g. having a “cancelAllConnectionsWithDelegate: self” method.