Posts

Post not yet marked as solved
0 Replies
446 Views
I have a document-based Mac app using the SwiftUI life-cycle. It works well except that I cannot work out how to tell which window is frontmost. So if I have a menu item that operates on a document, how can I apply it to the document in the frontmost window? Any approach using notifications or passthrough subjects gets applied to all open windows. I think that the focusable modifiers are supposed to deal with this, but they do not appear to work.
Posted
by SarahR.
Last updated
.
Post not yet marked as solved
1 Replies
793 Views
I have a simple test app with a list of items in a NavigationView List. When one is clicked, it fills in the data in a detail view called by a NavigationLink. If the app goes to the background, or the sidebar is completely collapsed, the detail view disappears. I see that it calls the view's onDisppear modifier. This does not happen with macOS Catalina but happens with Big Sur when using Xcode 12 with the new SwiftUI App lifecycle or Xcode 11 with the old UIKit life cycle. I have tried creating a state object that stores the selection, binding the selection in the NavigationLink and lots of other options, but I cannot work out how to persist the detail view. The Fruta sample app does this fine, but there is so much else going on there, that I cannot work out what bit is making this work. Any ideas?
Posted
by SarahR.
Last updated
.