So I have an app that populates a table from a shared store and when you click on a row it preforms a segue to more information and you can edit the item you clicked on(basic master-detail). For some reason once you edit the item and go back (I'm using a navigation controller as my root view) the change shows (in the app and in memory from as far as I can tell) until you refresh the data in the table(I refresh every time the view appears or new information is added to the table aka another row is added). All of the items properties show null or 0 even the ones you do not edit.
I have put NSLogs and breaks to try to find out whats going on but to no avail. If i do not try to save any changes made to the item in the detail view controller they will not be null but i have to be able to make changes and grab user input.
My problem seems similar to this thread iOS Master Detail app - detail shows only the first time but I do not understand the solution that was posted.
can anyone explain maybe what this solution is or know how to fix this problem?
any help would be appreciated!!
If you need a section of code please ask.
this is how I save the "feedItem" in the detail view controller
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// Clear first responder
[self.view endEditing:YES];
// "Save" changes to item
BYFItemFeed *item = self.item;
item.amount=self.amountField.text ;
item.netEnergyM=self.netEnergyMField.text ;
item.netEnergyG=self.netEnergyGField.text ;
item.crudePro=self.crudeProField.text ;
item.calcium=self.calciumField.text ;
item.phosphorus=self.phosphorusField.text ;
item.cost=self.costField.text ;
}
this is how I transfer from the master to the detail
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"BYFFeedDetail"])
{
NSIndexPath *indexPath = [[self tableView] indexPathForSelectedRow];
NSMutableArray *items= [[BYFFeedStore sharedStore] allItems];
BYFItemFeed *object = items[indexPath.row];
[[segue destinationViewController] setItem:object];
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"BYFFeedDetail" sender:self];
}
and this is how I populate the table
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Get a new or recycled cell
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
// Set the text on the cell with the description of the item
BYFItemFeed *item = [[BYFFeedStore sharedStore] allItems][indexPath.row];
// NSLog(@"\n\n %@",item);
cell.textLabel.text = [item description];
return cell;
}