title: Removing the duplicate value from Nsmutablearray+iphone
body: <p><strong>My edited Question:-</strong>
  I had copied the array.
  But the problem is when the below line executes 
   [mainRestaurantArray removeObjectAtIndex:j]; 
  the index of the mainRestaurantArray is reduces.And which will not allow to remove the proper indexed value</p>
  
  <p>As it shows the error of index out of bound.
  Becoz the total index of arrayRestaurantList -31
  and total index of mainRestaurantArray-25 (after removing the duplicate value).</p>
  
  <pre><code>if([arrayRestaurantList count]==[mainRestaurantArray count]){
      BtnMore.hidden=YES;
      TablView.frame=CGRectMake(0,57, 320, 360);
      }   else{
      [mainRestaurantArray removeAllObjects];
      mainRestaurantArray=[[NSMutableArray arrayWithArray:arrayRestaurantList] retain];
      if ([arrayRestaurantList count]&gt;10) {
          for (int i=0;i&lt;[arrayRestaurantList count]-10;i++) {
              NSString *Old_data;
              Old_data=[[arrayRestaurantList objectAtIndex:i] objectForKey:@"Name"];
              NSLog(@"olddata==&gt;%@",Old_data);
              for (int j=[arrayRestaurantList count]-10;j&lt;[arrayRestaurantList count];j++) {              
                  NSString *New_data;             
                  New_data=[[arrayRestaurantList objectAtIndex:j] objectForKey:@"Name"];
                  NSLog(@"olddata==&gt;%@ newdata==&gt;%@",Old_data,New_data);
                  if ([New_data isEqualToString:Old_data]) {
                      //BtnMore.hidden=YES;                   
                      [mainRestaurantArray removeObjectAtIndex:j];
  
                  }
              }
          }
      }
      }
  </code></pre>
  
  <p>I have a <code>NSMutableArray</code>(<code>mainRestaurantArray</code>) which is filled from the data which is coming as a response from webservice.</p>
  
  <p>The data in <code>mainRestaurantArray</code> are like:-</p>
  
  <pre><code>{
      Address = "Ellisbridge Opposite Parimal Garden Near Doctor House Ahmedabad Gujarat 380006 India (Collegian Restaurant)";
      Image = "";
      Latitude = "23.020119999999999";
      Longitude = "72.556343999999996";
      Name = "Collegian Restaurant";
      "Phone_Number" = "079 26401020";
      url = "";
  }
  {
      Address = "Ground Floor Aakash Ganga Ellisbridge B/H Gujrat College : Next To Art Palace Ellisbridge Ahmedabad Gujarat 380006 India (TC's Bread Shop)";
      Image = "";
      Latitude = "23.023137999999999";
      Longitude = "72.560096000000001";
      Name = "TC's Bread Shop";
      "Phone_Number" = "079 26568158";
      url = "";
  }
  {
      Address = "Center Point Panchwati Crossing C G Road Ahmedabad Gujarat 380009 India (Kings Food Factory)";
      Image = "";
      Latitude = "23.022670000000002";
      Longitude = "72.555651999999995";
      Name = "Kings Food Factory";
      "Phone_Number" = "079 4002 1122";
      url = "http://www.kingsfoodfactory.com";
  }
  </code></pre>
  
  <p>i.e in dictionary form.Now some time it happens that the data get repeated.So i want to remove it.
  I had written the code like below:</p>
  
  <pre><code>if ([mainRestaurantArray count]&gt;10) {
          for (int i=0;i&lt;[mainRestaurantArray count]-10;i++) {
              NSString *Old_data;
              Old_data=[[mainRestaurantArray objectAtIndex:i] objectForKey:@"Name"];
              NSLog(@"olddata==&gt;%@",Old_data);
              for (int j=[mainRestaurantArray count]-10;j&lt;[mainRestaurantArray count];j++) {              
                  NSString *New_data;             
                  New_data=[[mainRestaurantArray objectAtIndex:j] objectForKey:@"Name"];
                  NSLog(@"olddata==&gt;%@ newdata==&gt;%@",Old_data,New_data);
                  if ([New_data isEqualToString:Old_data]) {
                      BtnMore.hidden=YES;
                      TablView.frame=CGRectMake(0,57, 320, 360);
                      [mainRestaurantArray removeObjectAtIndex:j];
  
                  }
              }
          }
      }
  </code></pre>
  
  <p>But the problem in this code is when i remove the value the reference get lost..
  So application get crashed.Can anybody help me how to get remove the data</p>
  
  <p>Thanks in advance...</p>