ios - uitableview cell value not refresh according with the ones in coredata after change -


i'm building master-detail application, saying master view a(tableview), second-view(tableview) b, detail-view c. data core-data. in secondview(tableview), popover prompt cell value change when user tap specific cell. after change on popover screen, dismiss popover, return secondview(tableview) , update core data accordingly. , cell value expected reflect update value. issue doesn't work that. cell value still remains old ones, though core data update new value(i confirmed via nslog in method --tableview:cellforrowatindexpath. print cell's new value, display cell's old value). tried put table-view:reloaddata viewwillappear , popovercontrollerdiddismisspopover method, still doesn't work.

i cannot figure out it. cell value on secondview(tableview) update after return view master-view , again switch second-view b.

however, second view reflect new cell addition immediately, addition via popover prompt cell new value input.

would please this? thanks.

-(void) popovercontrollerdiddismisspopover:(uipopovercontroller *)popovercontroller {      //get text popover based on various class type     if([popovercontroller.contentviewcontroller iskindofclass:[changecellvalueviewcontroller class]])    {        nsstring *thenewinputcellvalue =((changecellvalueviewcontroller *)popovercontroller.contentviewcontroller).thecellvalue.text;        nsstring *oldcellvalue=((changecellvalueviewcontroller *)popovercontroller.contentviewcontroller).thecellvalueold.text;        if (0 != [ thenewinputcellvalue length] && oldcellvalue  !=  thenewinputcellvalue)     {             nsmanagedobjectcontext *acontext =  [self.masterviewmastercontroller.fetchedresultscontroller managedobjectcontext];             nsmanagedobject *celltobechanged = ((changecellvalueviewcontroller *)popovercontroller.contentviewcontroller).cellobjecttobechanged;            [ celltobechanged setvalue: thenewinputcellvalue forkey:@"cellvalue"];            // save context.            nserror *error = nil;            if (![acontext save:&error])            {                // replace implementation code handle error appropriately.                // abort() causes application generate crash log , terminate. should not use function in shipping application, although may useful during development.                nslog(@"unresolved error %@, %@", error, [error userinfo]);                abort();            }             if (![self.masterviewmastercontroller.fetchedresultscontroller performfetch:&error]) {           // replace implementation code handle error appropriately.           // abort() causes application generate crash log , terminate. should not use function in shipping application, although may useful during development.               nslog(@"unresolved error %@, %@", error, [error userinfo]);               abort();           }            [self.tableview reloaddata];         }      } }    - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@“cell” forindexpath:indexpath];      // configure cell...     if (cell == nil)     {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1 reuseidentifier:@“cell”];     }     nsmanagedobject *celllist =  [[self sortcells] objectatindex:indexpath.row];     cell.textlabel.text =   [[celllist valueforkey:@"cellname"] description];     nslog(@"cell text %@", cell.textlabel.text);     cell.accessorytype = uitableviewcellaccessorydisclosureindicator;      return cell; } 
  • (void)viewdidload { [super viewdidload];

    // uncomment following line preserve selection between presentations. // self.clearsselectiononviewwillappear = no;

    // uncomment following line display edit button in navigation bar view controller. // self.navigationitem.rightbarbuttonitem = self.editbuttonitem; [self.tableview registerclass:[uitableviewcell class] forcellreuseidentifier:@"cell"]; [self.tableview reloaddata]; }

please check if updating datasource of uitableview of second-view. can refresh cell value by

  1. reload cell updated datasource(i guess input popover update datasource of uitableview) using method -

[tableview reloadrowsatindexpaths:withrowanimation:]

  1. when input popover closes using popovercontrollerdiddismisspopover delegate in uitableviewcell can update label value popover

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -