title: NSArray containsObject method
body: <p>I have a simple question regarding xcode coding but don't know why things are not performing as I think.  I have an array of objects (custom objects).  I just want to check if this one is within the array.  I used the following code:</p>
  
  <pre><code>NSArray *collection = [[NSArray alloc] initWithObjects:A, B, C, nil]; //A, B, C are custom "Item" objects
  Item *tempItem = [[Item alloc] initWithLength:1 width:2 height:3];  //3 instance variables in "Item" objects
  if([collection containsObject:tempItem]) {
      NSLog(@"collection contains this item");
  }
  </code></pre>
  
  <p>I suppose the above checking will give me a positive result but it's not.  Further, I checked whether the objects created are the same.</p>
  
  <pre><code>NSLog(@"L:%i W:%i H:%i", itemToCheck.length, itemToCheck.width, itemToCheck.height);
  for (int i = 0, i &lt; [collection count], i++) {
      Item *itemInArray = [collection objectAtIndex:i];
      NSLog(@"collection contains L:%i W:%i H:%i", itemInArray.length, itemInArray.width, itemInArrayheight);
  }
  </code></pre>
  
  <p>In the console, this is what I got:</p>
  
  <pre><code>L:1 W:2 H:3
  collection contains L:0 W:0 H:0
  collection contains L:1 W:2 H:3
  collection contains L:6 W:8 H:2
  </code></pre>
  
  <p>Obviously the <code>tempItem</code> is inside the <code>collection</code> array but nothing shows up when I use <code>containsObject:</code> to check it.  Could anyone give me some direction which part I am wrong?  Thanks a lot!</p>