ReferenceFileDocument is for auto-saving documents in the background. It uses UndoManager to know when to save a document.
See this thread. - https://developer.apple.com/forums/thread/658590.
And here is a working example. - https://github.com/solarmist/EmojiArt