I have problems saving my MOC in a PersistentDocument.
I insert a new MO in my MOC and do a save (for e.g.)
NSManagedObject *person=[[NSManagedObject alloc] initWithEntity:[NSEntityDescription entityForName:@"Person" inManagedObjectContext:self.managedObjectContext] insertIntoManagedObjectContext:self.managedObjectContext];
if(person)
{
[person setValue:@"test" forKey:@"name"];
NSError *error;
[self.managedObjectContext save:&error];
}
I must save the MO at this point because I need a NOT temporary objectID of it for my background thread to do some calculation on the entity.
But when I save the MOC in this way, I get a requester
The document “Untitled.binary” could not be saved. The file has been changed by another application.
Click Save Anyway to keep your changes and save the changes made by the other application as a version, or click Revert to keep the changes from the other application and save your changes as a version.
the next time the Document is trying to save its content. I can not save the document instead, because it is possible that it is still an untitled document and a call of [document save] would open the save requester which ist not very comfortable for the user.
Is there any solution?
Thanks
Claus