How to set up a definition expression?

3169
1
04-14-2011 06:15 AM
StanislavGusakov
New Contributor II
Question update:
Which is the correct syntax to set a definition expression for "Identify" ?

Resolved:
NSString* defString = @"NAME='Mike'";
AGSLayerDefinition* layerDef = [AGSLayerDefinition  layerDefinitionWithLayerId:0 definition:defString];
identifyParams.layerDefinitions = [NSArray arrayWithObject: layerDef];


I have a Map and a feature layer.
In my feature layer there are a lot of features created by different people.
There is a field "NAME" with the feature creator's name.
So, to show the features created only by, let's say "Mike" I am trying to use the following code:

        NSURL *featLURL = [NSURL URLWithString:@"......"];
 self.featureLayer = [AGSFeatureLayer featureServiceLayerWithURL: featLURL mode: AGSFeatureLayerModeOnDemand];

 self.featureLayer.outFields = [NSArray arrayWithObject:@"*"];
        [self.featureLayer setDefinitionExpression:@"NAME=???Mike???"];
 [self.mapView addMapLayer:self.featureLayer withName:@"featurez"];
 self.featureLayer.editingDelegate = self;

Doesn't work. Every feature just disappears from the map. (but they still can be identified)
Any advices?

Edit 1:

it does work like this:
 NSString* defString = @"OBJECTID='1'"; 

But still doesn't work with strings.

Edit 2:
Mkkkay, after restarting the service everything started working. Strange.

Question update:
Which is the correct syntax to set a definition expression for "Identify" ?
0 Kudos
1 Reply
DiveshGoyal
Esri Regular Contributor
The syntax is the same for all definition expressions, be it on layers or tasks (wherever supported).
0 Kudos