Ios 地图注释索引编号不断更改

Ios 地图注释索引编号不断更改,ios,objective-c,annotations,mkmapview,mkannotationview,Ios,Objective C,Annotations,Mkmapview,Mkannotationview,我想在单击地图点时获取地图注释索引号,但我有一个问题,那就是当我第一次运行应用程序并单击显示索引=5的点时。但当我重新运行应用程序并再次单击同一点时,它会显示index=23。在我重新运行应用程序后,索引号一直在更改,并且在我单击的确切位置不会显示相同的索引号 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view { if ([view.annotation is

我想在单击地图点时获取地图注释索引号,但我有一个问题,那就是当我第一次运行应用程序并单击显示索引=5的点时。但当我重新运行应用程序并再次单击同一点时,它会显示index=23。在我重新运行应用程序后,索引号一直在更改,并且在我单击的确切位置不会显示相同的索引号

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
        if ([view.annotation isKindOfClass:[MKPointAnnotation class]]) {

            NSUInteger index = [mapView.annotations indexOfObject:view.annotation];
            NSLog(@"Index number is %lu", (unsigned long)index);
}

我找到了解决方案,我将一个位置ID保存到
annotation.title
中,然后我使用下面的代码替换索引号

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
        if ([view.annotation isKindOfClass:[MKPointAnnotation class]]) {
           NSString *hubIden = view.annotation.title;
       }
}

重复@ElTomato我需要在objc中,谢谢