I am trying to load in a bunch of features from a feature service on arcgis.com. I know the service is coming in just fine because it renders on the map. What I can't get it to do is to let me read out the features themselves. To my knowledge, I need to make a query on this feature layer and then I can parse out the results in a delegate method. However, my delegate method is never getting called, making me wonder if I am missing a step somewhere. Below is my code:
(void)viewDidLoad {
[super viewDidLoad];
AGSLocalTiledLayer *localLayer = [AGSLocalTiledLayer localTiledLayerWithName:@myname];
[self.mapView addMapLayer:localLayer withName:@Campus Basemap];
NSURL *url = [NSURL URLWithString:@myservicename];
AGSFeatureLayer *buildingPoints = [AGSFeatureLayer featureServiceLayerWithURL:url mode:AGSFeatureLayerModeOnDemand];
[self.mapView addMapLayer:buildingPoints withName:@BYU Buildings];
//set myself as the query's delegate
buildingPoints.queryDelegate = self;
AGSQuery *query = [AGSQuery query];
//no "where" clause because I want all the records
query.outFields = [NSArray arrayWithObjects:@FID, @Abbr, @Name, nil];
[buildingPoints selectFeaturesWithQuery:query selectionMethod:AGSFeatureLayerSelectionMethodNew];
[self.mapView.locationDisplay startDataSource];
}
- (void)featureLayer:(AGSFeatureLayer *)featureLayer operation:(NSOperation *)op didQueryFeaturesWithFeatureSet:(AGSFeatureSet *)featureSet {
//IT NEVER GETS IN HERE!
//populate all the points into an nsarray.
for (AGSGraphic *selectedFeature in featureSet.features){
Building *building = [[Building alloc] init];
building.fid = [[selectedFeature attributeForKey:@FID] integerValue];
building.abbreviation = [selectedFeature attributeAsStringForKey:@Abbr];
building.fullName = [selectedFeature attributeAsStringForKey:@Name];
}
}
- (void)featureLayer:(AGSFeatureLayer *)featureLayer operation:(NSOperation *)op didFailSelectFeaturesWithError:(NSError *)error {
//IT NEVER GETS HERE EITHER
NSLog(@Query Failed.);
}
Any ideas?