A search on the title of this post reveals that it's pretty common; indeed, I've gotten this error from Xcode. But I can't seem to find any fixes. I'm seeing it now when I run my program, and it appears to occur during or after changeCountTokenForSaveOperation is called. It seems related to the undo manager, rather than to the fact that i'm using core data, but I may be wrong.
Does anyone know what causes this or how to fix it?
Some users have only had the autosave issue occur when working with extremely large files; others, when they have lots of documents open. The General preference pane lets you set continuous saving for supported apps.
As you work away, the current state of the document is updated temporarily. When you close the file, changes are applied even if you don’t use the Save command or keystroke.
This error can occur with NSPersistentDocument when you perform a manual save in code on the managedObjectContext of your NSPersistentDocument class. The problem here is you're modifying the document on disk behind NSPersistentDocument's back.
So the correct solution is avoid saving manually. If you cannot avoid it, you can override fileModificationDate method of NSDocument to return the current file modification date of the file. Of this way the document does not show the error message. Show activity on this post.
This error can occur with NSPersistentDocument when you perform a manual save in code on the managedObjectContext
of your NSPersistentDocument class. The problem here is you're modifying the document on disk behind NSPersistentDocument's back. Just leave the save actions to the NSPersistentDocument and the error will not occur.
The problem is saving manually the managedObjectContext. So the correct solution is avoid saving manually. If you cannot avoid it, you can override fileModificationDate method of NSDocument to return the current file modification date of the file. Of this way the document does not show the error message.
- (NSDate *)fileModificationDate {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDictionary *attrs = [fileManager attributesOfItemAtPath:self.fileURL.path error:NULL];
return attrs[NSFileModificationDate];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With