Post

Replies

Boosts

Views

Activity

Swift UI DocumentGroup: write to FileWrapper and name document
How can I set a name for a new document which was just created after calling the write method from the FileDocument's protocol ?. I tried to use the properties from the FileWrapper class like '.filename': func write(to fileWrapper: inout FileWrapper, contentType: UTType) throws {         let data = text.data(using: .utf8)!         fileWrapper = FileWrapper(regularFileWithContents: data)         //fileWrapper.filename = "newName"          //fileWrapper.preferredFilename = "newName"     }
2
0
1.2k
Jul ’20
How to distinguish between adding and viewing in one DocumentGroup Scene?
The following scene will be created if the user select '+' in the navigation bar, but I don't want to execute the same code again if the user selects an item/file in the DocumentGroup. There is another initializer for selecting items in a DocumentGroup but how can I manage both possibilities (adding and showing) in one Scene? Furthermore how can I customize the DocumentGroup Navigation Bar? (I didn't find anything related to this in the documentation). struct DocumentApp: App {     var body: some Scene {         DocumentGroup(newDocument: 	DocumentAppDocument()) { file in ContentView(document: file.$document)}     } }
3
0
815
Jun ’20