Select to view content in your preferred language

Crash When Using AGSCalloutTemplate

824
1
06-24-2012 04:10 PM
CharlesJacobsen
New Contributor
I'm getting a mysterious crash when I try to use the simple AGSCalloutTemplate. As indicated in "Using AGSCalloutTemplate" here, one simply specifies the text template for the title and detail properties, and that's it. But it crashes when I tap on a graphic added in the following way:


    AGSPoint *p = [[AGSPoint alloc] initWithX:-111.0f y:40.0f spatialReference:[[AGSSpatialReference alloc] initWithWKID:4326]];
    
    
    AGSPictureMarkerSymbol *s = [[AGSPictureMarkerSymbol alloc] 
                                 initWithImageNamed:@"symbol_image.png"];
    
    NSMutableDictionary *attr = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                 
                                 @"San Diego", @"Title",
                                 @"Population 10,000", @"Detail",
                                 
                                 nil];

    AGSCalloutTemplate *temp = [[AGSCalloutTemplate alloc] init];
    temp.titleTemplate = @"${Title}";
    temp.detailTemplate = @"${Detail}";
    
    AGSGraphic *g = [[AGSGraphic alloc] initWithGeometry:p 
                                                  symbol:s 
                                              attributes:attr 
                                    infoTemplateDelegate:temp];
    
    [self.graphicLayer addGraphic:g];



I don't have anything fancy happening outside of this code; and the problem goes away when I either set the infoTemplateDelegate to nil in the graphic constructor, or use my own info template delegate (implementing the title and detail info provider methods). I have no trouble accessing the attributes dictionary in my delegate methods (when I implement my own delegate, instead of using AGSCalloutTemplate).

Does AGSCalloutTemplate expect the attributes dictionary to have some particular structure?

I can get by and will probably end up just making my own delegate, but I thought I would bring this to everyone's attention in case this is a bug. It looks like it's crashing in the AGSMapView method setupCalloutUIForGraphic:mapPoint:.
0 Kudos
1 Reply
NimeshJarecha
Esri Regular Contributor
Are you releasing the instance of AGSCalloutTemplate somewhere in your code?

It's crashing because you are not retaining it. Just create a retain property for the AGSCalloutTemplate and it'll work as expected.

Regards,
Nimesh
0 Kudos