Trouble with attributes in a AGSGDBFeature

2503
3
06-23-2016 06:34 AM
SvenAanesen
New Contributor II

I have trouble with access to one of the attributes in a AGSGDBFeature. Trying to figure out why I've created some dummy code to test it. The code collects all features where attribute "StorviltID" is equal to "24208" and then tries to print the value. The results returns one AGSGDBFeature, but the value in the attribute "StorviltID" is gone... How can this happen?

AGSGDBFeatureTable *table = [[GDOfflineManager sharedManager] getFeatureTableFromServiceNamed:@"SKUTT"andLayerId:@0];

    AGSQuery *q = [[AGSQuery alloc] init];

    q.whereClause = @"StorviltID = 24208";

   

    [table queryResultsWithParameters:q completion:^(NSArray *results, NSError *error) {

        for (AGSGDBFeature *feature in results) {

            NSLog(@"Found value for feature with StorviltID: %@", [feature valueForKey:@"StorviltID"]);

            NSLog(@"Found attribute for feature with StorviltID: %@", [feature attributeForKey:@"StorviltID"]);

            NSLog(@"Found attributeAsInteger for feature with StorviltID: %li", (long)[feature attributeAsIntegerForKey:@"StorviltID" exists:nil]);

        }

    }];

The StorviltID attribute is of type Integer, and as the code indicates I try many different methods for collecting the value but neither with any luck. Printing the entire feature also displays that the "StorviltID" is actually gone... How is this possible when the feature was found based on this attribute?

3 Replies
Nicholas-Furness
Esri Regular Contributor

Hi Sven,

You should set the AGSQuery.outFields property to include the fields you want to access on the returned features. So before you call queryResultsWithParameters, do something like:

q.outFields = @[@"StorviltID"];

Let me know if that doesn't work.

Cheers,

Nick.

SvenAanesen
New Contributor II

Hi @Nicholas

Thanks for answering.

We found the problem. It was actually the replica that was created on the device that created the "StorviltID" field as a float(64) instead of Integer. When recreating the field on the server as a small int and deleting the app on device and recreate the replica, the field appeared as a int(16) and problem was gone...

Guess there is some bug in the SDK when creating the replica on device?

Sven

0 Kudos
DiveshGoyal
Esri Regular Contributor

Technically, the replica is created by the server, and downloaded to the device, not created locally on the device. And we haven't seen any issues where the field type in the replica does not match the field type in the service. Is it possible that you changed the schema of the database underneath the service, but the service didn't pick it up and so it produced this problem?

0 Kudos