Post

Replies

Boosts

Views

Activity

Reply to Delayed save when tapping "back" button using a SwiftUI DocumentGroup
So I've narrowed it down to an odd issue with a NavigationLink. Using Xcode 12.5 when creating a new project (named Test3Document, please excuse the name) that is a document based app the ContentView.swift file created looks like this: struct ContentView: View {     @Binding var document: Test3Document     var body: some View {         TextEditor(text: $document.text)     } } Everything works fine when editing then tapping the back button. It saves instantly and you can see this by opening the document right up again. It is immediately reflected. When modifying it slightly like so: struct ContentView: View {     @Binding var document: Test3Document     var body: some View {         NavigationLink(             destination: TextEditor(text: $document.text),             label: {                 Text(document.text)             }         )     } } Tapping the label, then editing the text, hitting the back button to go back to the initial view reflects immediately. However tapping the back button to get to the DocumentGroup, then opening the same document does not immediately reflect the change. Waiting ~15 seconds does show the change though. Very strange!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’21