I have a simple app that I am developing. It stores one line to do list items in a core data model. I am completely new to core data. What I am trying to do is pass my managedObjectContext from my main viewcontroller to my second viewcontroller.
This is the prepareforsegue that I have:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"EditItemSegue"])
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
Item *item = [[self fetchedResultsController]objectAtIndexPath:indexPath];
EditItem *destination = (EditItem *)segue.destinationViewController;
destination.managedObjectContext=self.managedObjectContext;
destination.toDoItemName = item;
}
}Question 1: Is this correct?
Question 2: On my second viewcontroller, how do I grab the moc? I now how it works if I am using SQLite but I think I am getting things confused.
Also
destination.toDoItemName = item;This line complains: incompatible pointer types assigning nsstring to item
I know what this means but I am not completely sure how to resolve it in this situation.
My source is here: https://github.com/martylavender/LittleToDoApp/tree/addingcoredata
Any help with this would be very much appreciated.