AGSFindTask delegate not firing

622
7
12-19-2011 07:53 AM
DarrenMackiewicz
Occasional Contributor
Hi
I have already done 2 implementations of AGSFindTask.
The delegate fires as expected.

On a third one, both in the existing viewController, and if I move it to its own viewController, the delegate will not fire.

In the header file, I've specified the delegate


#import <UIKit/UIKit.h>
#import "ArcGIS.h"


@interface TelemetryViewController : UIViewController  <UITableViewDelegate, UIPopoverControllerDelegate, AGSFindTaskDelegate>{
   
    UIPopoverController* _popOverController;
    UITableView *_tableView;

    AGSFindTask *_findTask;
    AGSFindParameters *_findParams;
   
}

@property (nonatomic,retain) UIPopoverController* popOverController;
@property (nonatomic, retain) IBOutlet UITableView *tableView;

@property (nonatomic, retain) AGSFindTask *findTask;
@property (nonatomic, retain) AGSFindParameters *findParams;

@end


----
In my function, I set up the query with hard-coded variables that I know work through testing the query in REST, and I've set the delegate to equal self.  But, the delegate :
-(void)findTask:(AGSFindTask *)findTask operation:(NSOperation *)op didExecuteWithFindResults:(NSArray *)results {


never fires!

----


//create find task and set the delegate
    self.findTask2 = [[AGSFindTask alloc] initWithURL:[NSURL URLWithString:self.baseLayerURL]];

    self.findTask.delegate = self;
  
    //create find task parameters
    self.findParams = [[AGSFindParameters alloc]init];
   
    //set find task parameters
    self.findParams.contains = NO;
    self.findParams.layerIds = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],nil];
    self.findParams.outSpatialReference = self.mapView.spatialReference;
    self.findParams.returnGeometry = TRUE;
    self.findParams.searchFields = [NSArray arrayWithObjects:@"FTPID",nil];
  
   
    self.findParams.searchText = @"WTK001";
   
    //execute find task
    [self.findTask executeWithParameters:self.findParams];

--------
Has anyone else experienced this or have any idea what could be causing this?
I've checked the other forum posts on the idea and I've made sure I have the delegate in the header file and the delegate set to self in the implementation file.

Thanks
0 Kudos
7 Replies
NimeshJarecha
Esri Regular Contributor
You are initializing self.findTask2, setting delegate for self.findTask and executing self.findTask. So self.findTask is never initialized?

Regards,
Nimesh
0 Kudos
DarrenMackiewicz
Occasional Contributor
Typo when I copied it over. It really is self.findTask not self.findTask2
Problem still exists. (!)
I corrected the code below.



//create find task and set the delegate
self.findTask = [[AGSFindTask alloc] initWithURL:[NSURL URLWithString:self.baseLayerURL]];

self.findTask.delegate = self;

//create find task parameters
self.findParams = [[AGSFindParameters alloc]init];

//set find task parameters
self.findParams.contains = NO;
self.findParams.layerIds = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],nil];
self.findParams.outSpatialReference = self.mapView.spatialReference;
self.findParams.returnGeometry = TRUE;
self.findParams.searchFields = [NSArray arrayWithObjects:@"FTPID",nil];


self.findParams.searchText = @"WTK001";

//execute find task
[self.findTask executeWithParameters:self.findParams];
0 Kudos
NimeshJarecha
Esri Regular Contributor
The class from where you are executing the find task and the class where you adopted a AGSFindTaskDelegate are same?

If possible, attach a sample application to test.

Regards,
Nimesh
0 Kudos
DarrenMackiewicz
Occasional Contributor
Yes, Nimesh, that is true.

I discovered something playing around....

If I execute the findTask from within

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
}

the app delegate fires

If I try to execute it from within a custom function it does not.

- (void) runTelemQuery {
}

Is there some sort of dependency to running an AGSFindTask from a UITableView ? or other?
0 Kudos
NimeshJarecha
Esri Regular Contributor
Could you please post a sample app here, I would like to test.

Regards,
Nimesh
0 Kudos
DarrenMackiewicz
Occasional Contributor
Turns out, I was trying to run the AGSFindTask delegate from a different thread while in NSParserQueue.
I had to force the function to run on the main thread.
0 Kudos
NimeshJarecha
Esri Regular Contributor
Good to know that everything is working! 🙂

Regards,
Nimesh
0 Kudos