AnsweredAssumed Answered

IdentifyTask timing issue - iOS

Question asked by TSI-AR on Nov 13, 2015
Latest reply on Nov 17, 2015 by Gagandeep_Singh-esristaff

I'm using IdentifyTask to test for parcel content being present in an existing app, specifically as follows:

 

I set the parameters in ParcelController, then

        NSLog(@"Fetching Parcels with params");

        [identifyTask executeWithParameters:params];

 

Then test results in ParcelDelegate upon completion

-(void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results

{

    NSLog(@"Results.count: %li", results.count);  // this is the parcel count

    if (results.count > 0) {

.

.

.

 

This works fine, but now I'd like to be able to provide the user a warning if no content is present, this from the MapViewController. 

 

I added the following at the ParcelDelegate:

 

-(void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results

{

    contentPresent = NO;

    NSLog(@"Results.count: %li", results.count);

    if (results.count > 0) {

        contentPresent = YES;

 

At the MapViewController I use contentPresent to alert the user if no content is available.   The problem is that contentPresent never sets as true, there appears to be a thread issue in which didExecuteWithIdentifyResults: takes a while to execute, and my if(!contentPresent) test executes before didExecuteWithIdentifyResults: is invoked.

 

So I added another flag in didExecuteWithIdentifyResults: (contentChecked) to allow the MapViewController to wait until didExecuteWithIdentifyResults: is invoked.  That test simply results in the system getting stuck in a endless while(!contentChecked) loop.

 

I inherited this app and am by no means an expert in iOS or Objective-C.  I'm using global variables for contentChecked and contentPresent and have confirmed that they are indeed visible and addressable across all areas.  It appears that the identifyTask is not executing, but only if I try to pass information out of it using the global variables.  When I remark my changes out, it all works just fine.  Is there a thread issue with identifyTask I'm missing?

 

Any ideas or suggestions are most welcome!

 

Chuck

Outcomes