title: removing duplicates in nsarray
body: <p>how can i remove duplicates in nsarray. for instance my array contains following data. I want to compare with adjacent dates to avoid duplicates but it throughs error.</p>
  
  <p>Can anyone guide me what i am going wrong</p>
  
  <p>calendar first-</p>
  
  <pre><code>( 
  2010-09-25 17:00:00 GMT,
  "AAA",
  2010-09-25 17:00:00 GMT,
  "AAA",
  2010-09-26 17:00:00 GMT,
  "BBB",
  2010-09-26 17:00:00 GMT,
  "BBB",
  2010-09-27 17:00:00 GMT,
  "CCCC",
  2010-09-27 17:00:00 GMT,
  "CCC",
  2010-09-28 17:00:00 GMT,
  "AAA",
  2010-09-28 17:00:00 GMT,
  "AAA",
  2010-09-29 17:00:00 GMT,
  "DDDD",
  2010-09-29 17:00:00 GMT,
  "DDDD",
  2010-09-30 17:00:00 GMT,
  "BBBB"
  )
  </code></pre>
  
  <p>my code</p>
  
  <pre><code>NSArray dates; //dates contain above values
  NSMutableArray *temp_date = [[NSMutableArray alloc] init];
  
  for (int i=0; i&lt;[dates count]; i+=2){
      BOOL day;
  
      if ([dates count]-2 &gt;i) {
          day = [[dates objectAtIndex:i] compare:[dates objectAtIndex:i+2]];
      }   
  
      if (day) {
          [temp_date addObject:[dates objectAtIndex:i]];
          [temp_date addObject:[dates objectAtIndex:i+1] ];
      }
  }
  </code></pre>
  
  <p>Regards,
  sathish</p>