Problems getting any attribute values from clicked on AGSGraphic

1002
0
03-05-2013 06:58 AM
IanHogan1
New Contributor
I'm having trouble getting attribute information back off of an AGSGraphic that has been programmatically added to an AGSGraphicsLayer.

I'm creating an AGSGraphicsLayer, adding it to the AGSMapView. Population of graphics comes from an AGSQueryTask. The graphics from the Query task response have attributes which I can read and work with. If I add the graphics to the layer, they appear on the map correctly.

However, if I later reference them via the graphics collection in mapView:didClickAtPoint:mapPoint:graphics, trying to reference graphic.allAttributes will crash the application, along the lines of:

[NSArrayI allAttributes]: unrecognized selector sent to instance 0x......


The code I'm using to reference the graphic looks like this:

-(void) mapView:( AGSMapView * ) mapView didClickAtPoint: ( CGPoint)screen mapPoint: ( AGSPoint * ) mappoint graphics: ( NSDictionary * ) graphics
{
       [INDENT] for (NSString* key in graphics)
        {
            [INDENT]AGSGraphic *fieldGraphic = [graphics objectForKey:key];
           
            NSDictionary* attributeDictionary = fieldGraphic.allAttributes; //will crater here[/INDENT]
         }[/INDENT]
}

I can look at the content of the retrieved AGSGraphic in the debugger, and see the format, which looks something like this:

Printing description of fieldGraphic:
[INDENT]<__NSArrayI 0x14405640>[INDENT](
geometry: AGSPolygon: [envelope: AGSEnvelope: xmin = -10737628.615600, ymin = 6029925.460000, xmax = -10734567.173800, ymax = 6031121.366800, spatial reference: [AGSSpatialReference: wkid = 102100, wkt = null]], symbol: <AGSSimpleFillSymbol: 0x9cdec80>, attributes: {
    "FIELD_ID" = 167788;
}, visible: 1[/INDENT]
)
[/INDENT]

where FIELD_ID is the value I'd like to retrieve. So basically all the content seems to be there, but not resolvable as an AGSGraphic.

I've tried directly adding the AGSGraphic from the Query task response, creating new graphics and new attribute dictionary with the values added directly, etc, but it always comes back the same way.

Any ideas?

Thanks,
Ian
0 Kudos
0 Replies