title: Select a map annotation from array programatically
body: <p>I've got an array of places. Each of these places are displayed on a MapView and on a TableView on the same screen. I'd like to pop up the pin annotation of a place when I tap the corresponding row on the table view.</p>
  
  <p>I've got the following code to populate annotations:</p>
  
  <pre><code>for (int i = 0; i &lt; [self.myPlaces count]; i++)
      {
          MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
          SPlaces *ev = [self.myPlaces objectAtIndex:i];
          point.coordinate = CLLocationCoordinate2DMake([ev.location.latitude doubleValue], [ev.location.longitude doubleValue]);
          point.title = ev.title;
          point.subtitle = ev.type.name;
          [self.myMap addAnnotation:point];
      }
  </code></pre>
  
  <p>and this code to display an annotation when a row is selected on the TableView:</p>
  
  <pre><code>//row = tapped row on TableView
      [self.myMap selectAnnotation:[[self.myMap annotations] objectAtIndex:row] animated:YES];
  </code></pre>
  
  <p>The issue is that the annotations seems to have a random index in the myMap annotations array.
  I mean, i'd like to have this behavior:</p>
  
  <pre><code>users taps row 0 on Table view =&gt; annotation of pin 0 pops up on the map
  users taps row 1 on Table view =&gt; annotation of pin 1 pops up on the map
  users taps row 2 on Table view =&gt; annotation of pin 2 pops up on the map
  </code></pre>
  
  <p>But instead of this, I get:</p>
  
  <pre><code>users taps row 0 on Table view =&gt; annotation of pin 1 pops up on the map
  users taps row 1 on Table view =&gt; annotation of pin 0 pops up on the map
  users taps row 2 on Table view =&gt; annotation of pin 2 pops up on the map
  </code></pre>
  
  <p>...or any other random combination that change each time I restart the app.
  Note that if I enable user's location, one of my pin annotation can have it's title randomly changed for "Current location".</p>
  
  <p>I'm pretty sure I'm note populating or accessing the annotation correctly. Do you have any clue ?</p>
  
  <p>Thanks !</p>
  
  <p><strong>EDIT:</strong> This post seems to say that you have to scan your annotations array, looking for a matching title, then select the relevant annotation : <a href="https://stackoverflow.com/questions/17214295/open-map-annotation-from-selected-row-in-table-view?rq=1">Open Map Annotation from Selected Row in Table View</a>
  Is this really the only way ? Since two pins could possibly share the same title, it seems a little bit hazardous...</p>