Domains [possible values] of a field of an object.

647
2
03-25-2011 04:15 AM
StanislavGusakov
New Contributor II
How to return a list of allowed values (domain) for a specific field (Field key) of a specific object (ID)?

For instance, I have an object "ObjectA" on the map with ID = 12345. It has a field: "Married?" and it has only 2 possible values: "Yes" and "No".

So, how to return a list of possible values in the code?

Thanks in advance.
2 Replies
StanislavGusakov
New Contributor II
No information on this?
0 Kudos
StanislavGusakov
New Contributor II
My solution:
Feel free to use.
NSArray *fieldz = [featureLayer fields];
NSString *neededField = @"FIELD_NAME";

 for (int i = 0; i<[fieldz count]; i++)
 {
  AGSField *currentField = [fieldz objectAtIndex:i];
  NSString *fieldName = currentField.name;
  if ([fieldName isEqualToString:neededField])
  {
   NSArray *domains = [[currentField domain] codedValues];
   if (domains)
   {
    NSLog(@"%@", currentField.name);
    for (int a = 0; a < [domains count]; a++) 
    {
    NSLog(@"NAME = %@ ; CODE = %@", [[domains objectAtIndex:a] name], [[domains objectAtIndex:a] code]);
    }
   }
  
   NSLog(@"domain test complete");
  }
 }