Re: NSDocument annoying warning
Re: NSDocument annoying warning
- Subject: Re: NSDocument annoying warning
- From: Mike Abdullah <email@hidden>
- Date: Sat, 15 Nov 2008 00:14:24 +0000
I would suggest that you rearrange your code slightly to match how the
document architecture expects it to operate.
Move your package-modification code to be part of the -writeToURL: or -
saveToURL: method of your document subclass. Then, when opening a
document, check if the upgrade needs doing, and if so, call the
appropriate document -save method.
Mike.
On 14 Nov 2008, at 23:21, Randall Meadows wrote:
The NSDocument class reference contains this note:
"As of Mac OS X v10.5, this method checks to see if the document's
file has been modified since the document was opened or most
recently saved or reverted, in addition to the checking for file
moving, renaming, and trashing that it has done since Mac OS X
v10.1. When it senses file modification it presents an alert telling
the user "This document’s file has been changed by another
application since you opened or saved it,” giving them the choice of
saving or not saving. For backward binary compatibility this is only
done in applications linked against Mac OS X v10.5 or later."
I am getting that alert, since when I now open a document (which is
actually a bundle) in this application, I create a new file in the
document's bundle, indicating that it is a "new and improved"
version of the file; this new file is a modified version of another
file in the bundle, which I leave in place so as to maintain
backward compatibility for older versions of this application
(deployment at the client's site will not be 100%, and people using
both old and new versions will be opening documents, and I want them
both to continue working).
Now, that alert is actually a lie, since it isn't "another
application" that made the change. My application did it on
purpose, and I want those changes to stick.
In addition, when the app opens the document, it changes the
extension to indicate that this particular document is in use (since
it's typically opened from a server, and multiple users could be
working in the same folder, and we use this as an alert to the 2nd
user that someone's already working on this particular file. As of
10.5, we now get a warning dialog upon a save attempt that "This
document has been renamed to foobar.newextension". Yes, I know, the
app did that.
Is there something I can do to tell NSDocument (or whomever) that
these changes that it thinks are made by another application are on
purpose, and that it needs to keep its opinions regarding them to
itself? If <whatever> ends up marking the file as "dirty", that's
fine by me. I'll go continue scouring the docs, but if someone has
a pointer, I'd appreciate it.
Thanks!
randy_______________________________________________
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
_______________________________________________
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