권정근
권정근

Reputation: 11

Result of 'NavigationLink<Label, Destination>' initializer is unused

.toolbar(content: { ToolbarItem( placement: .topBarLeading, content: { NavigationLink( // Notes: destination: { ThirdSubView() }, label: { Image(systemName: "person") } ) } )

                    ToolbarItem(
                        placement: .topBarTrailing,
                        content: {
                            NavigationLink(
                                destination: {
                                    SecondSubView()
                                },
                                label: {
                                    Image(systemName: "gear")
                                }
                            )
                        }
                    )

                })

Upvotes: -2

Views: 3433

Answers (1)

Jonas Lang
Jonas Lang

Reputation: 354

NavigationLink is a view. Don't use it in an closure. My suggestion should work, but could not test it because there are to many specific things in your example. Try to use code that works out of the box, so everybody can test.

List {
    ForEach(listViewModel.items) { item in
        NavigationLink(
            destination: AddView(),
            label: {
                ListRowView(item: item)
                    .onTapGesture (count:2){
                        withAnimation(.linear) {
                            listViewModel.updateItem(item: item)
                        }
                    }
            }
        )
    }
    .onDelete(perform: listViewModel.deleteItem)
    .onMove(perform: listViewModel.moveItem)
    
}
.listStyle(InsetListStyle())

Upvotes: 0

Related Questions