I´m having trouble re-saving records in my core data, and i was hopping someone could help me understanding what am i missing here:
When i want to save a record, i have my "product" tableview with the code below:
- (IBAction)save:(id)sender
{
MyCoreDataClass *productOne = [NSEntityDescription insertNewObjectForEntityForName:@"MyCoreDataClass" inManagedObjectContext:self.managedObjectContext];
productOne.reference = reference.text;
productOne.type = type.text;
productOne.cost = cost.text;
[self.managedObjectContext save:nil];
[self dismissModalViewControllerAnimated:YES];
}
As you already understood i have a "Product List" tableview, where all the records are being displayed/saved nicely, and in my "Product List" didSelectRowAtIndexPath method i have done this:(i´m not using segues!)
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCoreDataClass *produtoSelected = (Lista *)[[self fetchedResultsController] objectAtIndexPath:indexPath];
if ([produtoSelected.reference isEqualToString:@"shirts"]||[produtoSelected.reference isEqualToString:@"pants"] )
{
Product *example=(Product *)[self.storyboard instantiateViewControllerWithIdentifier:@"ProductId"];
produto.modalPresentationStyle = UIModalPresentationFormSheet;
produto.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:example animated:YES];
produto.view.superview.frame = CGRectMake(0, 0, 350, 510); //do this after presentModalViewController
example.view.superview.center = self.view.center;
example.reference.text = produtoSelected.reference;
example.type.text = produtoSelected.type;
example.cost.text = produtoSelected.cost;
example.managedObjectContext = self.managedObjectContext;
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
The previous saved information is displayed, after that I already tried the "self.managedObjectContext refreshObject" and i know that my last line is not correct...The delegate of my "Product" tableview is my "Product List" tableview...and i have seen examples where the user enters in EDIT mode, but i just don´t want that...i just want the user to press in the desire row, modify what he wants and hit the save button...
What am i missing, i´m losing hours here...could anyone help me?
Thanks in advance for you time.