duplicate()
Creates a new document whose contents are the same as the receiver and returns an error object if unsuccessful.
Declaration
func duplicate() throws -> NSDocumentReturn Value
The new document if duplication is successful; otherwise nil.
Discussion
The new document returned doesn’t yet have a value to return from fileURL.
The default implementation of this method first uses writeSafely(to:ofType:for:) to write the document’s current contents to a file located in the same directory that is used for the autosaved contents of untitled documents and with the same sort of name, then invokes [[NSDocumentController sharedDocumentController] duplicateDocumentWithContentsOfURL:newContentsURL copying:NO displayName:aDisplayName error:outError].
You can override this method to customize what is done during document duplication, but if your override does not invoke [NSDocumentController duplicateDocumentWithContentsOfURL:copying:displayName:error:] you must take care to do things that that method does, especially invoking [NSDocumentController addDocument:] and [NSFileCoordinator addFilePresenter:].