-1

Today i started to use ADClusterMapView ( https://github.com/applidium/ADClusterMapView ) and studied the example project... so i decided to add the content to my project... every thing was OK no red errors... the simulator turned on and posted a thread... I'm trying to figure out the problem for hours... so maybe you have idea where the problem is...

-(void)viewDidLoad {

   [ADClusterMapView class];
   NSArray* airports = [Airport allAirports];
   [mapView setAnnotations:airports];
   [mapView setVisibleMapRect:MKMapRectWorld];
}

-(MKAnnotationView*)mapView:(MKMapView *)aMapView viewForAnnotation:(id<MKAnnotation>)annotation {
static NSString* reuseIdentifier = @"airportAnnotation";

    if ([annotation isKindOfClass:[Airport class]]) {
        MKAnnotationView* annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:reuseIdentifier];
        if (!annotationView) {
            annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier] autorelease];
            annotationView.canShowCallout = YES;
    }
        annotationView.image = ((Airport*)annotation).icon;
        return annotationView;
    }
}


- (MKAnnotationView *)mapView:(ADClusterMapView *)aMapView viewForClusterAnnotation:(id<MKAnnotation>)annotation {
MKAnnotationView * annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"ADMapCluster"];
if (!annotationView) {
    annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
                                            reuseIdentifier:@"ADMapCluster"]
               autorelease];
    annotationView.image = [UIImage imageNamed:@"circle.png"];
    annotationView.canShowCallout = YES;
}
else {
    annotationView.annotation = annotation;
}
    return annotationView;
}

the Error in debuger was:

Airports[3489:c07] -[MKMapView setAnnotations:]: unrecognized selector sent to instance 0x8095570 Airports[3489:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKMapView setAnnotations:]: unrecognized selector sent to instance 0x8095570' * First throw call stack: (0x1945012 0x1275e7e 0x19d04bd 0x1934bbc 0x193494e 0x2b6e 0x29e817 0x29e882 0x1eda25 0x1ee311 0x28db 0x1ba7b7 0x1bada7 0x1bbfab 0x1cd315 0x1ce24b 0x1bfcf8 0x18a0df9 0x18a0ad0 0x18babf5 0x18ba962 0x18ebbb6 0x18eaf44 0x18eae1b 0x1bb7da 0x1bd65c 0x282d 0x2765) libc++abi.dylib: terminate called throwing an exception sharedlibrary apply-load-rules all Current language: auto; currently objective-c

ABundzs
  • 13
  • 1
  • 5
  • At first, I tried myself to use ADClusterMapView but I finally ended up building my own simple clustering system, inspired by WWDC 2011 presentation. If you want to have a look, check my answer http://stackoverflow.com/a/20271466/1394534. There are both codes for Google SDK and MapKit – Aurelien Porte Dec 26 '13 at 10:28
  • Than you! Do you have a example project in github or something like that? – ABundzs Dec 27 '13 at 19:01

2 Answers2

1

[mapView setAnnotations:airports]; seems to be the problem. From doc, only addAnnotations:, addAnnotation: and their remove equivalent are available. Plus, annotations property is readonly so setAnnotations crashes, normal

Aurelien Porte
  • 2,692
  • 27
  • 32
1

Apparently, it's happening because you forgot to change the Custom Class on Identity Inspector (right side Utilities). Simply set the value to ADClusterMapView.

Igor de Lorenzi
  • 573
  • 1
  • 7
  • 18