Double Dealloc messages


#1

Hi,

I added a dealloc override to the person class. This caused two identical NSLog messages to be issued when an Employee object is released. This kinda makes sense because to instantiate a Employee object, a Person object has to instantiated, too. This is what confuses me: shouldn’t the height and weight be displayed instead of a second Employee description? Thanks in advance for lifting the fog.

Regards,

Phil


#2

Hi, Phil,

Although it is executing the two dealloc methods, -[Person dealloc] and -[Employee dealloc], both are calling [self description], and self is an instance of Employee. Thus, -[Employee description] is getting executed in both cases.

  • Aaron