我正在 Xcode 12 中使用新的 MultiPlatform SwiftUI 文档模板,但我不明白如何从菜单项中访问当前的 FileDocument。
我的应用程序代码如下所示(直接来自模板)。
@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")
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1503 次 |
| 最近记录: |