Accessing Map service info?

Discussion created by AndrewE on Aug 18, 2010
Latest reply on Oct 3, 2011 by wherewhy

I'm trying to read the visible status of individual layers in a map service at start up so I can set if they are visible or not, but I am having no luck accessing the Map Service Info, here is my code:

 // Get indexes of visible layers
 AGSMapServiceInfo *dynaServiceInfo = self.dynamicLayer.mapServiceInfo;
 AGSMapServiceLayerInfo *dynaLayerInfo;
 NSMutableArray *visibleLayers = [NSMutableArray arrayWithCapacity:[dynaServiceInfo.layerInfos count]];
 for (int i = 0; i < [dynaServiceInfo.layerInfos count]; i++) {
  dynaLayerInfo = [dynaServiceInfo.layerInfos objectAtIndex:i];
  if (dynaLayerInfo.visible == YES) {
   [visibleLayers addObject:[[NSNumber alloc] initWithInt:i]];

My AGSMapServiceInfo object is always empty, but I'm not sure what I'm doing wrong. I've also tried directly accessing the layerInfos, and creating an array from them with no success either.
Any help appreciated.