I see this "new" NavigationLink in Apples documentation:
I am upgrading my working code from a depreciated NavigationLink with "destination" to a NavigationStack with a value.
But, I can not get XCode to accept any syntax I can come up with using a Label ().
Here is what I have tried (along with other variations). XCode chokes on this and says it is too complex.
NavigationLink( value: sidebar, { Label(sidebar.title, systemImage: SFSymbolsModel.icon[sidebar.type] ?? "questionmark" ) })
I need a Label (I think - it is what I used before) because I want to format the displayed text with an Icon.
All of the examples I can find use a string to provide the label. Does "Label" in the documentation not mean an actual Label, like we have in the depreciated version?
Can anyone provide me a one- or two-line example of the correct syntax?
If you want to use this syntax for NavigationLink, you need to add label
before closure:
NavigationLink( value: sidebar, label: { Label(sidebar.title, systemImage: SFSymbolsModel.icon[sidebar.type] ?? "questionmark" ) })
Or you can write it with a trailing closure
NavigationLink( value: sidebar) { Label(sidebar.title, systemImage: SFSymbolsModel.icon[sidebar.type] ?? "questionmark" ) }