nijkampr

Adding callout (InfoTemplateDelegate) results in crash

Discussion created by nijkampr on Apr 17, 2012
Latest reply on May 14, 2013 by gthorne
Hi all,

I'm adding some graphics manually to the map, with the following code:

        double lat = [(NSNumber *) [colleague objectForKey: @"Latitude"] doubleValue];
        double lon = [(NSNumber *) [colleague objectForKey: @"Longitude"] doubleValue];
        
        if ( !(lat == 0.00 && lon == 0.00))
        { 
            AGSSimpleMarkerSymbol *pointMarker = [AGSSimpleMarkerSymbol simpleMarkerSymbolWithColor:[UIColor orangeColor]];
            pointMarker.size = 15; //[(NSNumber *) [colleague objectForKey: @"Precision"] intValue];
            pointMarker.style = AGSSimpleMarkerSymbolStyleCircle;    
            
            AGSPoint *wgspoint = [AGSPoint pointWithX:lon y:lat spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]];
            AGSGeometry *mapPoint = [_geometryEngine projectGeometry:wgspoint toSpatialReference:self.mapView.spatialReference];
            
//            LocationInfoTemplate * template = [[LocationInfoTemplate alloc] init];
            AGSCalloutTemplate* template = [[AGSCalloutTemplate alloc] init] ;
            template.titleTemplate = @"${Username}"; 
            template.detailTemplate = @"${TimeStamp}"; 
            
            AGSGraphic *location = [[AGSGraphic alloc] initWithGeometry: mapPoint 
                                                                 symbol: pointMarker 
                                                             attributes: [colleague mutableCopy]
                                                   infoTemplateDelegate: template]; //template];

            [_trackLayer addGraphic:location];
            //template = Nil;
        }


I've got the following issue.
When the user taps on the graphic, the callout is supposed to be shown. But the application crashes in some SDK assembly, to be specific:

0x0011bed8  <+0052>  tst.w r0, #255 ; 0xff
in the [AGSMapView setupCalloutUiForGraphic:mapPoint]

I've tried to use my own TemplateClass (LocationInfoTemplate) and the AGSCalloutTemplate class, both had the same result.

To debug this, i've added the following function:

- (BOOL)mapView:(AGSMapView *)mapView shouldShowCalloutForGraphic:(AGSGraphic *)graphic {
    NSLog(@"Click");
    
    return true;
}

Just to see what's in the Graphic object.

And i was surprised:
First run: _infoTemplateDelegate UIImage * 0xde9ad50
Second run: _infoTemplateDelegate __NSCFNumber * 0xde9acd0

I think i can say that the infoTemplate is NOT retained!

What's the problem here?
I'm using the 2.1 SDK, i'm using the latest Xcode (With ARC) and the latest iOS....

--Edit-- Updated tot 2.2.1 SDK, same behavior.

Outcomes