I have a map display controller (UIViewController, MKMapView) with its delegate (HCIResultMapViewController).
I want to have the following functionality in this part.
1). I want to use my own NSObject so that I can link other details along with basic objects like title, subtitles, etc.
Therefore, according to my needs, I am encoded as follows
In HCIResultMapViewController
- (void)viewDidLoad {
[super viewDidLoad];
_houseList = [[_resultList objectForKey:@"result"] objectForKey:@"listings"];
int i = 0;
for (NSDictionary *house in _houseList) {
HCIAnnotationViewController *annotation = [[HCIAnnotationViewController alloc]
initwithHouse:house];
[_mapView addAnnotation:annotation];
self.currIdentifier = i;
i++;
}
[_mapView setShowsUserLocation:NO];
}
Other delegate features
-(void) mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
for (NSObject<MKAnnotation> *annotation in _mapView.selectedAnnotations) {
NSLog(@"hellomaster");
NSLog(annotation.title);
if ([annotation isKindOfClass:[HCIAnnotationViewController class]]) {
NSLog(@"hellomaster");
}
}
Last
-(MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
NSString *identifier = @"currIdentifier";
MKPinAnnotationView *annotationView =
(MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.tag = self.currIdentifier;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[annotationView setRightCalloutAccessoryView:rightButton];
return annotationView;
}
But I see that class equivalence fails. Can you tell me what I am doing wrong?
I think I want, in simple words, how can I send some data (NSDictionary *) along with the annotation so that I can receive it when I want?
, . , Google .., .