objective c - How to filter a Parse query by an tableview index? -


i have uitableviewcontroller in application. in table performing parse query:

-(ibaction)joinevent:(id)sender {   pfquery *query = [pfquery querywithclassname:@"event"]; [query selectkeys:@[@"vacants"]]; [query wherekey:@"username" equalto:pfuser.currentuser.username]; [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) {     if (!error) {         // find succeeded.         nslog(@"successfully retrieved %lu scores.", (unsigned long)objects.count);         // found objects           (nsobject *object in objects){              nsstring *a = [object valueforkey:@"vacants"];             nslog(@"vacants %@", a);           }     } else {         // log details of failure         nslog(@"error: %@ %@", error, [error userinfo]);     }      [self.tableview reloaddata]; }]; 

}

this query gets me vacants in parse cloud.

what want able vacants indexpath.row of table.

so far have tried use

-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath;  

instead of ibaction, still same result. using approach don't know how call didselectrowatindexpath ibaction, believe solve issue.

this cellforrowatindexpath method:

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {  static nsstring *cellid = @"cell";  tfgresultstableviewcell *cell= [tableview dequeuereusablecellwithidentifier:cellid forindexpath:indexpath];  if(cell == nil) {     cell = [[tfgresultstableviewcell alloc]             initwithstyle:uitableviewcellstyledefault             reuseidentifier:cellid]; }  // configure cell...  cell.eventnamelabel.text = [eventnamearray objectatindex: [indexpath row]];  cell.userlabel.text = [userarray objectatindex: [indexpath row]]; cell.sportlabel.text = [sportarray objectatindex: [indexpath row]]; cell.eventdatelabel.text = [datearray objectatindex: [indexpath row]]; cell.eventhourlabel.text = [hourarray objectatindex: [indexpath row]]; cell.eventplacelabel.text = [placearray objectatindex: [indexpath row]]; cell.vacantslabel.text = [vacantsarray objectatindex: [indexpath row]]; cell.citylabel.text = [cityarray objectatindex: [indexpath row]];  if([cell.sportlabel.text isequaltostring:@"soccer" ]){      cell.eventimage.image = [uiimage imagenamed:@"soccerballicon.png"]; } else{      cell.eventimage.image = [uiimage imagenamed:@"icon.png"];  }  return cell; 

}

add data parse server global array , set delegate table view via code or in soryboard.

nsarray *copyarray = objects; yourtableview.delegate = self ; 

in delegatemethod-

-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath{      nsstring *a = [[copyarray objectatindex:indexpath.row]valueforkey:@"vacants"]; } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -