AnsweredAssumed Answered

Querying local geodatabase "EXC_BAD_ACCESS" error

Question asked by philopiman on May 30, 2014
Latest reply on Jun 4, 2014 by philopiman
I'm trying to query a local-geodatabase and display the results in a TableView however i'm having a thread error "EXC_BAD_ACCESS". I assume cause i have to be on the main thread to update the UI. I've tried using the performSelectorOnMainThread:@selector(reloadData) on the tableView but no luck!


<property for table array>
@property (nonatomic, strong) NSArray *localGDBQueryResult;



<method to query the database>
-(void) localgeodatabaseSearchForValue:(NSString*)searchString {   NSError *GDBError;   AGSGDBGeodatabase *gdb = [AGSGDBGeodatabase geodatabaseWithName:@"mygeodb" error:&GDBError];         if (gdb) {      AGSGDBFeatureTable *table = [gdb featureTableForLayerName:@"Mileposts"];          NSString *fieldname = @"MPOINT";     AGSQuery *query = [[AGSQuery alloc] init];     query.where = [NSString stringWithFormat:@"%@ = '%@'",fieldname, searchString];          [table queryResultsWithParameters:query           completion:^(NSArray *results, NSError *error) {                              if (!error) {                   self.localGDBQueryResult = results;                   [self.searchDisplayController.searchResultsTableView performSelectorOnMainThread:@selector(reloadData)                                                                                         withObject:nil                                                                                      waitUntilDone:NO];               } else {                   // Log details of the failure                   NSLog(@"Error: %@ %@", error, [error userInfo]);               }           }];   } }




<tableview methods>
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {  return 1; }  - (NSInteger)tableView:(UITableView *)tableView  numberOfRowsInSection:(NSInteger)section {  return [self.localGDBQueryResult count]; }  - (UITableViewCell *)tableView:(UITableView *)tableView          cellForRowAtIndexPath:(NSIndexPath *)indexPath {  UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"];       if (!cell) {      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault                                       reuseIdentifier:@"cell"];  }     cell.textLabel.text = [[self.localGDBQueryResult objectAtIndex:indexPath.row] valueForKey:@"RoadName"];  return cell; } 

Outcomes