Dear list,
I have an app which works with autosave and Versions browser. However, I have
discovered some strange behaviour. If I have a file (text file) open in the
app, and the file is somehow accessed on disk (doing touch on the file is
enough), the app jumps in and out of the Versions browser in a most bizarre
way. It really goes bananas, to employ a technical term.
I tested the same actions with TextEdit, and there the problem doesn't happen,
so it's clearly something with my app.
I think I tracked this down to a call to -revertDocumentToSaved:. I have a
file-monitor in the app which reloads the document if it changes on disk
(silently if there are no in-app edits; with an alert if there are). For the
reloading I was simply calling -revertDocumentToSaved:. If I don't do that and
instead use the same routine I use when the document opens, the problem goes
away. But it leaves me with a different problem. In the file-loading method I
call
[self setFileModificationDate:[NSDate date]];
[self updateChangeCount:NSChangeCleared];
if the load was successful. But now when I try to save the document from within
the app (after further edits) I get the usual
"The document “foo.txt” could not be saved. The file has been changed by
another application."
alert. Is there something else I should do to convince the NSDocument machinery
that the in memory version of the document is in sync with the on-disk version?
Cheers,
Martin
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]