title: Objective-C code not deallocating memory!
body: <p>I'm trying to learn Objective-C. I almost finished one excercise but it is not deallocating the memory:</p>
  
  <p>This is is what I have:</p>
  
  <pre><code>void PrintPolygonInfo() {
      NSLog(@"--------------------");
      NSLog(@" PRINT POLYGON INFO");
      NSLog(@"--------------------");
      NSMutableArray *array = [[NSMutableArray alloc] init];
      PolygonShape *p1 = [[PolygonShape alloc] initWithNumberOfSides:4 minimumNumberOfSides:3 maximumNumberOfSides:7];
      PolygonShape *p2 = [[PolygonShape alloc] initWithNumberOfSides:6 minimumNumberOfSides:5 maximumNumberOfSides:9];
      PolygonShape *p3 = [[PolygonShape alloc] initWithNumberOfSides:12 minimumNumberOfSides:9 maximumNumberOfSides:12];
      [array addObject:p1];
      [array addObject:p2];
      [array addObject:p3];
      // Log the descriptions
      for (id shape in array) {
          NSLog(@"%@", shape);
      }
      // Test the constraints
      for (PolygonShape *shape in array) {
          [shape setNumberOfSides:10];
      }
      [p1 release];
      [p2 release];
      [p3 release];
  }
  </code></pre>
  
  <p>This is the dealloc():</p>
  
  <pre><code>- (void) dealloc {
      NSLog(@"Deallocated!!!");
      [super dealloc];
  }
  </code></pre>
  
  <p>And this are the results:</p>
  
  <pre><code>2009-11-19 06:58:17.030 Assignment 1B[5441:a0f] --------------------
  2009-11-19 06:58:17.030 Assignment 1B[5441:a0f]  PRINT POLYGON INFO
  2009-11-19 06:58:17.031 Assignment 1B[5441:a0f] --------------------
  2009-11-19 06:58:17.031 Assignment 1B[5441:a0f] init: Retain count of 1.
  2009-11-19 06:58:17.032 Assignment 1B[5441:a0f] init: Retain count of 1.
  2009-11-19 06:58:17.032 Assignment 1B[5441:a0f] init: Retain count of 1.
  2009-11-19 06:58:17.033 Assignment 1B[5441:a0f] Hello I am a 4-sided polygon (aka a Square) with angles of 90 degrees (1.570796 radians).
  2009-11-19 06:58:17.033 Assignment 1B[5441:a0f] Hello I am a 6-sided polygon (aka a Hexagon) with angles of 120 degrees (2.094395 radians).
  2009-11-19 06:58:17.034 Assignment 1B[5441:a0f] Hello I am a 12-sided polygon (aka a Dodecagon) with angles of 150 degrees (2.617994 radians).
  2009-11-19 06:58:17.034 Assignment 1B[5441:a0f] Invalid number of sides: 10 is greater than the maximum of 7 allowed
  2009-11-19 06:58:17.035 Assignment 1B[5441:a0f] Invalid number of sides: 10 is greater than the maximum of 9 allowed
  </code></pre>
  
  <p>As you can see, it is not printing the 'Deallocated!!!" message:</p>
  
  <p>Can anyone tell me what I am doing wrong please?</p>
  
  <p>Thanks in advance</p>