How to check if web service is returning data?

795
1
Jump to solution
02-19-2014 08:46 AM
DinaLi
by
New Contributor
This is a simple question. For an iOS app, I display several maps. Occasionally, a mapping service may not be available. Using the ESRI sample code, I'm passing the URL to the layer object like this:

  NSURL *mapUrl4 = [NSURL URLWithString:@"http://gis.ers.usda.gov/arcgis/rest/services/foodaccess/MapServer"];
   
  dynamicLyr4 = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL:mapUrl4];

  [self.mapView addMapLayer:dynamicLyr4 withName:@"Food Access"];

It appears as though if the map service is not working, the code still returns a map layer, but it's empty. The code doesn't raise an exception. So my question is how should I be checking for cases where a service is down? Is there a specific property that I can check in the returned map layer?

Thanks for your help.
0 Kudos
1 Solution

Accepted Solutions
--2
by
New Contributor
You can implement
- (void)layer:(AGSLayer *)layer didFailToLoadWithError:(NSError *)error { // Your error handler here }
from the AGSLayer class to catch any errors in loading the layer.

You can see how it can be done in this example https://developers.arcgis.com/os-x/sample-code/featurelayereditingsample/

View solution in original post

0 Kudos
1 Reply
--2
by
New Contributor
You can implement
- (void)layer:(AGSLayer *)layer didFailToLoadWithError:(NSError *)error { // Your error handler here }
from the AGSLayer class to catch any errors in loading the layer.

You can see how it can be done in this example https://developers.arcgis.com/os-x/sample-code/featurelayereditingsample/
0 Kudos