title: Filter a NSMutableArray index beyond bounds Problem
body: <p>I am trying to filter a <code>NSMutableArray</code>. Search array for items by certain country.  I have tried <code>NSpredicate</code> which works great however I need to re-use the original array which I cannot with <code>NSpredicate</code>. So I am trying the below code. </p>
  
  <p>Q. What is the best way to filter an <code>NSMutableArray</code> keeping the original array intact?</p>
  
  <p>//The following code works</p>
  
  <pre><code>filteredArray = [[NSMutableArray alloc] init];
  unsigned int i;
  for (i = 0; i &lt; [appDelegate.arrayToBeFiltered count]; i++) {
      id session = [appDelegate.ads objectAtIndex: i];
      id Country = [[appDelegate.arrayToBeFiltered objectAtIndex: i] TheCountry];
      [filteredArray addObject: session];
  </code></pre>
  
  <p>However when I add the if statement as below I get index beyond bounds</p>
  
  <pre><code>filteredArray = [[NSMutableArray alloc] init];
  unsigned int i;
  for (i = 0; i &lt; [appDelegate.arrayToBeFiltered count]; i++) {
      id session = [appDelegate.ads objectAtIndex: i];
      id Country = [[appDelegate.arrayToBeFiltered objectAtIndex: i] TheCountry];
      if (Country == @"United States"){
          [filteredArray addObject: session];
      }
  }
  </code></pre>