title: Objective-C: dealloc not getting called
body: <p>I am learning Objective-C and using the Big Nerd Ranch's Obj-C book to familiarize myself with the language. Everything is going good so far until I reach this one exercise where I am supposed to create 2 classes where each of them inherits the <code>dealloc</code> method. The goal to show when an object actually gets deallocated. So the new dealloc looks like</p>
  
  <p><strong>Asset.h</strong></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  @class Employee;
  
  @interface Asset : NSObject{
      NSString * label;
      unsigned int resaleValue;
  }
  
  @property (strong) NSString * label;
  @property unsigned int resaleValue;
  
  @end
  </code></pre>
  
  <p><strong>Employee.h</strong></p>
  
  <pre><code>#import "Person.h"
  @class Asset;
  
  @interface Employee : Person
  {
      int employeeID;   
      NSString * lastName;
      Person * spouse;
      NSMutableArray * children;
      NSMutableArray * assets;
  }
  
  @property int employeeID;
  - (void) addAssetObject: (Asset *) a;
  - (unsigned int) valueOfAssets;
  
  @end
  </code></pre>
  
  <p><strong>Implementations</strong></p>
  
  <pre><code>@implementation Employee
  //omitted
      -(void) dealloc
      {
          NSLog(@"deallocating %@", self);
      }
  @end
  
  
  @implementation Asset
  //omitted
      -(void) dealloc
      {
          NSLog(@"deallocating %@", self);
      }
  @end
  </code></pre>
  
  <p><strong>main.m</strong></p>
  
  <pre><code>int main (int argc, const char * argv[])
  {
  
      @autoreleasepool {
  
          NSMutableArray * employees = [[NSMutableArray alloc] init];
          for(int i = 0; i&lt; 10; i++){
              Employee * person = [[Employee alloc] init];
              [person setWeightInKilos:90+i];
              [person setHeightInMeters:1.8 - i/10.0];
              [person setEmployeeID:i];
              [employees addObject:person];
          }
  
          for(int i = 0; i&lt; 10; i++){
              Asset * asset = [[Asset alloc] init];
              NSString * currentLabel = [NSString stringWithFormat:@"Laptop %d", i];
              [asset setLabel:currentLabel];
              [asset setResaleValue:i*17];
  
              NSUInteger * randomIndex = random() % [employees count];
              Employee * randomEmployee = [employees objectAtIndex:randomIndex];
  
              [randomEmployee addAssetObject:asset];
          }
  
          NSLog(@"Employees: %@", employees);
          NSLog(@"Giving up ownership of one employee");
          [employees removeObjectAtIndex:5]; // This is supposed to trigger the deallocate method
          NSLog(@"Giving up ownership of array");
          employees = nil;
      }
      return 0;
  }
  </code></pre>
  
  <p>Of course <code>description</code> is already inherited so that <code>%@</code>would work. However, when I ran it. The dealloc is not getting called and I am not getting the print outs that deallocates the object. I am not sure what I am doing wrong here.</p>
  
  <p>Sidenote: Shouldn't the dealloc do <code>[super dealloc]</code> as well?</p>