I have a question.
First I created an object that extends NSObject, I provided overrides for the description and dealloc methods. Here is my Employee.m file:
@implementation Employee ..... -(NSString *)description { return [NSString stringWithFormat:@"Employ ID: %d has $%d value of assets", [self employeeID], [self valueOfAssets]]; } -(void)dealloc { NSLog(@"deallocating.. %@", self); [super dealloc]; }
In my main.m, I first created an NSMutableArray to store a list of Employee objects:
NSMutableArray *employees = [[NSMutableArray alloc] init]; for (int i =0; i< 10; i++) {
and in the end I installed employees on nil
employees = nil;
I expected the dealloc method for each Employee object to be called, and I will see several logs, for example:
deallocating.. Employ ID 0 has value..... deallocating.. Employ ID 2 has value..... ....
However, I did not see any logs, and if I set a breakpoint in the dealloc method, the breakpoint would never hit.
Any thoughts?
source share