ios - tableview segue to another view controller -


i new programming , hung on simple problem. using parse array in tableview. when row selected want segue search bar on view controller. segue works fine , tableview works fine can't seem objectid pass.

#import "bookmarkviewcontroller.h" #import "parse/parse.h" #import <parseui/parseui.h> #import "viewcontroller.h"  @implementation bookmarkviewcontroller  @synthesize postarray;   #pragma mark - view lifecycle  - (void)viewdidload {     [super viewdidload];      [self.navigationitem setleftbarbuttonitem:[[uibarbuttonitem alloc]                 initwithbarbuttonsystemitem:uibarbuttonsystemitemrefresh target:self       action:@selector(refreshbuttonhandler:)]];  }  - (void)viewwillappear:(bool)animated {     if ([pfuser currentuser])         [self refreshbuttonhandler:nil]; }  #pragma mark - button handlers  - (void)refreshbuttonhandler:(id)sender {     //create query post object current user     pfquery *postquery = [pfquery querywithclassname:@"post"];     [postquery wherekey:@"author" equalto:[pfuser currentuser]];      // run query     [postquery findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) {         if (!error) {             //save results , update table             postarray = objects;             [self.tableview reloaddata];         }     }]; }  #pragma mark - table view data source  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:      (nsinteger)section {     // return number of rows in section.     return postarray.count; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:    (nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";      uitableviewcell *cell = [tableview    dequeuereusablecellwithidentifier:cellidentifier];     if (cell == nil) {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault   reuseidentifier:cellidentifier];     }      // configure cell textcontent of post cell's text label     pfobject *post = [postarray objectatindex:indexpath.row];     [cell.textlabel settext:[post objectforkey:@"textcontent"]];      return cell; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath     *)indexpath{     nslog(@"cell tapped");     pfobject *post = [postarray objectatindex:indexpath.row];     nslog(@"%@", post.objectid);     [self performseguewithidentifier:@"searchbookmark" sender:self];    } - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {     viewcontroller *vc = [segue destinationviewcontroller];      vc.labeltext = post.objectid;       } }   @end 

at vc.label.text use of undeclared identifier "post" can't seem figure out how recognized. in above method.

the nslogs reply correctly 16:17:27.513 [app] cell tapped [app] cgdvy7eu9h

change didselectrowatindexpath , prepareforsegue this:

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath* )indexpath{     [self performseguewithidentifier:@"searchbookmark" sender:self]; }  - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender  {     nsindexpath *indexpath = [self.tableview indexpathforselectedrow];      nslog(@"cell tapped");     pfobject *post = [postarray objectatindex:indexpath.row];     nslog(@"%@", post.objectid);     viewcontroller *vc = [segue destinationviewcontroller];      vc.labeltext = post.objectid;         } } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -