File changed by other application after saving
File changed by other application after saving
- Subject: File changed by other application after saving
- From: Antonio Nunes <email@hidden>
- Date: Tue, 18 Dec 2007 12:49:32 +0000
Hi,
After saving my untitled file successfully, if I then try to save
again, the following alert pops up:
"This document’s file has been changed by another application since
you opened or saved it."
...with the option to save or not save.
The app is an NSDocument based app whose documents are packages. It
uses the "Open" dialog to open both its native file format and to open
PDF documents. To open documents my NSDocument subclass overrides
readFromURL:ofType:error: which opens PDF documents in the following
way:
-uses the passed in pathname as the location from which to read the
PDF document.
-sets up any dependencies
-sets file type to the app's native file type
-sets file URL to nil
-issues [self updateChangeCount:NSChangeDone] so that the user can
save the file. (After all, effectively an untitled file was created
into which a PDF was automatically imported, which is a change, and
the user definitely needs to be able to save the file in native format
without having to resort to Save As)
The saving is done by
saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo
: which detaches a drawingThread to save the file, since saving tends
to be a rather expensive process. The saving routine does the following:
-It checks if the directory already exists at the specified saving
path. If not it creates it. So within the domain of the issue a
directory is create here.
-It saves whatever it needs to save (or update) within the save
directory.
-If the document's fileURL is nil or not equal to the save path it
sets the fileURL to the new path.
-It sets the document's change count to NSChangeCleared.
At this point an untitled document has been created and the PDF
document has been successfully imported. The document can now be
operated upon. When I issue the save command again I get the error
message quoted above. But no other app _has_ changed the file. I must
be missing something, but what?
-António
----------------------------------------------------
There is a world of difference between
searching for happiness and choosing
to be happy.
----------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden