- (void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results { //clear previous results [self.graphicsLayer removeAllGraphics]; if ([results count] > 0) { //add new results AGSSymbol* symbol = [AGSSimpleFillSymbol simpleFillSymbol]; symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5]; // for each result, set the symbol and add it to the graphics layer for (AGSIdentifyResult* result in results) { result.feature.symbol = symbol; [self.graphicsLayer addGraphic:result.feature]; } //set the callout content for the first result //get the state name NSString *stateName = [((AGSIdentifyResult*)[results objectAtIndex:0]).feature.attributes objectForKey:@STATE_NAME]; self.mapView.callout.title = stateName; self.mapView.callout.detail = @Click for more detail..; //show callout [self.mapView showCalloutAtPoint:self.mappoint forGraphic:((AGSIdentifyResult*)[results objectAtIndex:0]).feature animated:YES]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@Identify Result message:@No Result Found! delegate:nil cancelButtonTitle:@OK otherButtonTitles:nil]; [alert show]; [alert release]; } //call dataChanged on the graphics layer to redraw the graphics [self.graphicsLayer dataChanged]; }
Just change your didExecuteWithIdentifyResults code as following and it won't crash...- (void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results { //clear previous results [self.graphicsLayer removeAllGraphics]; if ([results count] > 0) { //add new results AGSSymbol* symbol = [AGSSimpleFillSymbol simpleFillSymbol]; symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5]; // for each result, set the symbol and add it to the graphics layer for (AGSIdentifyResult* result in results) { result.feature.symbol = symbol; [self.graphicsLayer addGraphic:result.feature]; } //set the callout content for the first result //get the state name NSString *stateName = [((AGSIdentifyResult*)[results objectAtIndex:0]).feature.attributes objectForKey:@STATE_NAME]; self.mapView.callout.title = stateName; self.mapView.callout.detail = @Click for more detail..; //show callout [self.mapView showCalloutAtPoint:self.mappoint forGraphic:((AGSIdentifyResult*)[results objectAtIndex:0]).feature animated:YES]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@Identify Result message:@No Result Found! delegate:nil cancelButtonTitle:@OK otherButtonTitles:nil]; [alert show]; [alert release]; } //call dataChanged on the graphics layer to redraw the graphics [self.graphicsLayer dataChanged]; }Regards,Nimesh
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.