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?
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.
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
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?