magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

Passing core data object from one controller to another without saving #1232

Open ordinaryman09 opened 8 years ago

ordinaryman09 commented 8 years ago

I'm trying to pass core data object from one controller to another without saving the changes. but I'mgetting CoreData: error: Mutating a managed object 0x14f70f510 Here's the code:

- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {  

NSManagedObjectContext *localContext = [NSManagedObjectContext MR_context];  
Item *item = [Item MR_createEntityInContext:localContext];  
item.code = indexPath.row;  
NextController *controller = [[NextController alloc] initWithItem:item];  
[self.navigationController pushViewController:controller animated:YES];  
}  

The reason why I don't want to save the data right away because I want to wait until the user finished the process of creating the new item. I can do this with creating regular object but since I already have the data model with core data, it seems redundant create two models.