I am trying to open a detail viewController when a user taps on the callout from a map annotation.
I have created a custom annotation subclass called myAnnotation, and there I have included a property called idEmpresa.
At a custom method I am declaring the annotation as follows:
double latitud = [[[categorias objectAtIndex:i] objectForKey:@"latitud"] doubleValue];
double longitud = [[[categorias objectAtIndex:i] objectForKey:@"longitud"]doubleValue];
CLLocationCoordinate2D lugar;
lugar.latitude = latitud;
lugar.longitude = longitud;
NSString *nombre = [[categorias objectAtIndex:i] objectForKey:@"titulo"];
CLLocationCoordinate2D coordinate3;
coordinate3.latitude = latitud;
coordinate3.longitude = longitud;
myAnnotation *annotation3 = [[myAnnotation alloc] initWithCoordinate:coordinate3 title:nombre ];
annotation3.grupo = 1;
int number = [[[categorias objectAtIndex:i] objectForKey:@"idObjeto"] intValue];
annotation3.idEmpresa = number;
NSLog(@"ESTA ES LA ID DE LA EMPRESA %d",number);
[self.mapView addAnnotation:annotation3];
You may see that the annotation has an attribute annotation3.idEmpresa
.
Then, at method calloutAccessoryControlTapped
I need to have access to this attribute. I know how to access the annotation title and subtitle inside that method:
NSString *addTitle = [[view annotation] title ];
NSString *addSubtitle = [[view annotation] subtitle ];
But it doesn't work for the attribute idEmpresa
NSString *addTitle = [[view annotation] title ];