Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically save causes document to think other app changes doc when re-opening file

This is pretty weird and I would very much appreciate all help =)

I have a document based app where it should be possible to perform some actions on the document file. To do so I'm saving the document every time the document actions are called. To do so I'm using the method:

saveDocumentWithDelegate:didSaveSelector:contextInfo:

The problem is, that when closing the document, reopening it from the recent files menu and then performing the action again I'm being presented with the dialog box saying that

This document’s file has been changed by another application since you opened or saved it.

However this is not the case when using the save menu item.

I've tried with different save methods:

saveToURL:ofType:forSaveOperation:error:

And even though this results in the behavior I'm looking for there is a side effect: The save menu item becomes deactivated after performing the action.

So my question is: How should I correctly perform save operations programmatically? I've looked through the docs but I haven't seen anything which looks like an obvious solution.

All help is appreciated. Thanks

like image 519
Jakob Dam Jensen Avatar asked Oct 06 '10 13:10

Jakob Dam Jensen


1 Answers

I found solution for this problem in my case. Problem was in options in overriding of configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error: method of NSPersistentDocument. Problem was solved when I delete string

[options setObject:[NSNumber numberWithBool:YES] forKey:NSSQLiteManualVacuumOption]

I used vacuum option for some reason. Don't know how but it caused problem with saving. When I refused this option the problem has disappeared.

like image 188
Lloyd18 Avatar answered Oct 02 '22 12:10

Lloyd18