i am trying to understand something.
in class A , i am creating an instance of classB , which there -in B , there is a timer, that ALWAYS repeat, and he fire a recording and playing system-forever.
in class A, i create the instance of B with :
recordMachine *recMinst=[[recordMachine alloc]init];
[recMinst startMachine];
[recMinst release];
the thing is, that in classB there are instance variables in the interface, such as the player,recorder pointers, and other integers.
the question is, how this classB continue to work, after i release the instance in A ??
doesnt A create a place in memory to store all the B instance variables and when i release it -they disappear ?
Yes and no, release does not work like C++ delete for example, it does not delete the object and clean its memory, but only decrease its reference count. If another object is holding onto it, then it won’t get deallocated until that other object has also called release on it.
The only explanation as to why B continues to work is because some other object is holding onto it.
You mention class B uses a timer (most likely an NSTimer) which you would have passed your B instance to. Thus NSTimer is keeping a reference to your B object and preventing it from getting destroyed.
Check the ref count on your instance to be sure.
NSTimer documentation says “The target object is retained by the timer and released when the timer is invalidated.”