How do I handle two different custom document types in one macOS document app?
Starting from the macOS Document App template I define two types, which are also registered in the info.plist :
extension UTType {
static var test1: UTType {
UTType(exportedAs: "com.exapmple.test1")
}
}
extension UTType {
static var test2: UTType {
UTType(exportedAs: "com.example.test2")
}
}
Apple documentation says:
Your app can support multiple document types by adding additional document group scenes:
But the shown example has only one type that can be created, the other is read only (Editor mode).
If I do this in the main app struct (which is basically boilerplate from the template:
@main
struct MultipleDocumentsApp: App {
var body: some Scene {
DocumentGroup(newDocument: DocumentOne()) { file in
Content1View(document: file.$document)
}
DocumentGroup(newDocument: DocumentTwo()) { file in
Content2View(document: file.$document)
}
}
}
..the resulting New menu looks like this, and I can only create documents of type 1:
Obviously I would need two different New... menu items for the two doc types. Any ideas how I can achieve this?
