I´m having trouble understanding how to use a core data entity variable between views, and for better understanding of what my issue is, my code is below:
View A:
At some point i´m doing this when a save button is pressed:
- (void)guardarOrcamento
{
newBudget=[NSEntityDescription insertNewObjectForEntityForName:@"Budget" inManagedObjectContext:context];
newBudget.relationshipBetweenEntityBudgetAndClient = myEntityClientVariable;
UIAlertView *saved = [[UIAlertView alloc]initWithTitle:@"Budget Saved" message:@"" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[saved show];
NSError *error;
[context save:&error])
}
View B:
My problem is in this view, i need to connect another relationship and for that, my "newBudget" variable most not be empty!:
- (void) setSelectedRowInTableview:(int)line
{
rowEntity=[NSEntityDescription insertNewObjectForEntityForName:@"rowEntity" inManagedObjectContext:context];
rowEntity.relationshipBetweenEntityRowEntityAndBudget = newBudget;
....
This RowEntity can only exist if Budget entity already exists...and at this point it does!...in the other view i have inserted a new object and saved it...and i understand why the variable "newBudget"(in view B) is empty, but how can i persist it?
Thanks for you time