I am using the new MultiPlatform SwiftUI Document template in Xcode 12 and I don't understand how to get access to the current FileDocument from within a menu item.
My app code looks like this (straight from the template).
@main
struct MyApp: App {
var body: some Scene {
DocumentGroup(newDocument: MyDocument()) { file in
ContentView(document: file.$document)
}
.commands {
CommandMenu("Utilities") {
Button(action: {
// How to get access to the current FileDocument ?
}) {
Text("Test")
}
}
}
}
}