Hi all,
In a macOS document based app, I'm using this code to open all the documents contained in a folder inside Application Support.
The code works fine but the open documents are not maintaining the position they had when closed.
[....]
for file in myFileNames {
let fileName = "\(file).docuExperiments"
let directoryURL = appSupportURL.appendingPathComponent(bundleIdentifier).appendingPathComponent("Documents")
let docURL = URL(string: fileName, relativeTo:directoryURL)
let documentController = NSDocumentController.shared()
documentController.openDocument(withContentsOf: docURL!, display: true) {
// completionHandler (NSDocument?, Bool, Error?)
(document, documentWasAlreadyOpen, error) in
if error != nil
{ print("An error occured")
}
}
}
[....]And
override func windowDidLoad() {
super.windowDidLoad()
self.windowFrameAutosaveName = "position"
// this seems to affect only the first automatically created document window
}Can you help me to improve the code?
PS
Somebody knows also if there also is the possibility to open all the documents in a unique tabbed window?