How to get annotation indexpath in mapview
<p>I have a problem.<br>
I have a mapView, and I have many annotations in my mapView.<br>
how to know the <code>indexPath</code> that I select the annotation.<br>
I find the function <code>didSelectAnnotationView</code> but I don't know how to use it.</p>

<p>This is my code:</p>

<pre><code> BOOL firstLocationReceived;

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray&lt;CLLocation *&gt; *)locations
{
    CLLocation *currentLocation = locations.lastObject; //current location

    if(firstLocationReceived == NO)
    {
        MKCoordinateRegion region = _shopMapView.region;
        region.center = currentLocation.coordinate;
        region.span.latitudeDelta = 0.05;
        region.span.longitudeDelta = 0.05;

        [_restaurantMapView setRegion:region animated:true];

        //Add Annotation

        for (int i = 0; i &lt; self.items.count ; i++) 
        {
            MKPointAnnotation *annotation = [MKPointAnnotation new];

            NSDictionary *item = self.items[i];

            CLLocationDegrees latitude = [item[@"latitude"] doubleValue];
            CLLocationDegrees longitude = [item[@"longitude"] doubleValue];

            annotation.coordinate = CLLocationCoordinate2DMake(latitude, longitude);
            annotation.title = item[@"name"];
            annotation.subtitle = item[@"address"];

            [_shopMapView addAnnotation:annotation];

          firstLocationReceived == YES;
        }
    }
}

-(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation
{
    if (annotation == mapView.userLocation)
    {
        return nil;
    }

    NSString *identifier = @"shop";

    MKAnnotationView *result = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

    if(result ==nil)
    {
        result = [[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:identifier];
    }
    else
    {
        result.annotation = annotation;
    }
    result.canShowCallout = true;

    UIImage *annotationViewImage = [UIImage imageNamed:@"point.png"];
    result.image = annotationViewImage;

    result.leftCalloutAccessoryView = [[UIImageView alloc]initWithImage:annotationViewImage];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
    result.rightCalloutAccessoryView = button;

    return result;
}
</code></pre>

<p>Thanks!   </p>