title: Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x117540> was mutated while being enumerated
body: <p>Im gettin the  "Collection was mutates while beign enumerated" exception when my code is like this as follows:</p>
  
  <pre><code>NSString *poiStr = nil;
      int SuccessValue=0;
      NSMutableArray* poisArray=[[NSMutableArray alloc]init];
      for (id&lt;MKAnnotation&gt; annotation in mainMapView.annotations)
      {
          MKAnnotationView* anView = [mainMapView viewForAnnotation: annotation];
          if(anView)
          {
  
              POI* locationPOI = (POI*)[anView annotation];
              printf("\n Location poi shape groupId:%s=====%s",[locationPOI.shapeSpaceGroupId UTF8String],[poiStr UTF8String]);
              if((poiStr == nil) || ([poiStr isEqualToString:locationPOI.shapeSpaceGroupId]))
              {
  
                  poiStr = locationPOI.shapeSpaceGroupId;
                  [poisArray addObject:locationPOI];
                  SuccessValue++;
              }
              printf("\n successValue:%d",SuccessValue);
              if(SuccessValue==2)
              {
                  POI* poi=[poisArray objectAtIndex:0];
                  [mainMapView removeAnnotation:poi];
                  SuccessValue--;
              }
  
          }      
  
      }
  </code></pre>
  
  <p>Can anyone please suggest me what's the wrong in the code and how to solve the issues.</p>
  
  <p>Thanks to all,
  Madan.</p>