Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect overwritten file using NSDocument

I have an OSX app which uses NSDocument and autosaves inplace - all works well. Sometimes the user will save the document into a Dropbox synced folder and there is then the chance that the document will be updated (via Dropbox) whilst its still open in the app. Question is, how do I detect this and reload the document from disk (or at least inform the user.)

Thanks

like image 987
Scotty Avatar asked Oct 14 '25 12:10

Scotty


1 Answers

NSDocument implements the NSFilePresenter protocol out of the box. You can override presentedItemDidChange to update automatically when the file has changed.

like image 189
David Beck Avatar answered Oct 17 '25 03:10

David Beck