Это интерфейс BridgeAnnotation с делегатом MKAnnotation
@interface BridgeAnnotation : NSObject <MKAnnotation>
{
}
@property(nonatomic,retain) NSString *lat,*lon,*titlevalue,*subtitlevalue;
@property(nonatomic,assign) NSInteger myindex;
@end
Я устанавливаю значение переменной myindex в моем методе, как показано ниже
BridgeAnnotation *bridgeAnnotation = [[BridgeAnnotation alloc] init];
[bridgeAnnotation setLat:[@"" stringByAppendingFormat:@"%f",theCoordinate.latitude]];
[bridgeAnnotation setLon:[@"" stringByAppendingFormat:@"%f",theCoordinate.longitude]];
[bridgeAnnotation setTitlevalue:[PMLObj ProductTitle]];
[bridgeAnnotation setSubtitlevalue:[[PMLObj ProductPrice] stringByAppendingFormat:@"$"]];
[bridgeAnnotation setMyindex:i];
[self.mapView addAnnotation:bridgeAnnotation];
Это мой метод перебора
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)
[mapView dequeueReusableAnnotationViewWithIdentifier:BridgeAnnotationIdentifier];
if (!pinView)
{
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSLog(@"---%d",rightButton.tag);
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
return customPinView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
В приведенном выше методе я хочу получить доступ к myindex класса BridgeAnnotation ..
Как это возможно? ИЛИ Я должен использовать другой метод для этого ??
Кто-нибудь может мне помочь?