NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

NavigationSplitView questions

Forums > SwiftUI

I am trying to port an applicaiton I am working on for MacOS to use the new NavigationSplitViews.

Two issues have come up:

  1. When run I get this message repeatedly:

"Update NavigationAuthority bound selection tried to update multiple times per frame."

  1. The following is the heart of the navigation I am using (simplified). If my content is a TextEditor(...) it works correctly. If I use the NSTextView/Representable - CustomTextEdit in the code below it doesn't work. It did/does work with the older style of NavigationLinks.

The editor is initialized before any items in the list are clicked on and are not updated when a different row in the list is clicked. BUT. If I save the document, and reopen the saved, the clicked on row is presented. So, the issue is the NSTextView is not getting updated. Any suggestions would be greatly apprecaited.

Also, the Text view in the detail section is being updated corrected when rows in the sidebarlist are clicked on.

EDITED: I can see the $document.model.selected is not being updated on clicking/selecting a row.

struct ContentView: View {

    @Binding var document: HermesDocument

    var body: some View {

        NavigationSplitView(columnVisibility: $columnVisible) {
            if let children = document.model.sidebar.children {
                List(children, id: \.self, children: \.children, selection: $document.model.selected) { sidebar in
                    Label(, systemImage: SFSymbolsModel.icon[sidebar.iconName] ?? "questionmark")
                .navigationSplitViewColumnWidth(min: 200, ideal: 250)

        } content: {
            CustomTextEditor(text: $document.model.selected.text)
                .frame(width: 600.0)

        } detail: {
            VStack {
                Text(document.model.selected.text?.string ?? "empty")
                    .frame(width: 200.0)


A bit of help from anyone that has used NSTextView: Representable.

Apparantly in the previous method of NavigationLink the view (CustomTextView: NSTextView, Representable) was destroyed and recreated everytime you clicked on a row in the list. Now, it appears to create the view when the ContentView is created, and then leaves that view alive. The NSTexstView Coordinator.updateNSView is getting called, but I don't know how to tell it to replace the Text.

Do I just place the new text into TextView like this, and if so, do I have to delete the old or will replacing it this way deal with the memory allocation? (Sorry, I am an old school C/C++ programmer, and I worry constantly about memory allocation/deallocation.)



Why do you have two nested NavigationSplitView in your code? And even if, the second var body: some View { should go away.

Thanks that was a copy/paste error when posting. Apparently the browser didn't show the older version wasn't replaced.

Should be fixed now.


Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.