Problem with views

Problem: When I tap a song in PlaylistView, I want to navigate to PlayerPlaylistView and play that song. But I get the error:
Missing argument for parameter 'selectedAudioURL1' in call

App setup:
3 tabs: Home, Playlist, Settings

PlaylistView is supposed to pass selectedAudioURL1 to PlayerPlaylistView using a @Binding.

File 1 – PlayerView:

.navigationDestination(isPresented: Binding(
    get: { selectedTab == "playlist" },
    set: { isActive in
        if !isActive { selectedTab = "home" }
    }
)) {
    PlaylistView() // ❗️Missing argument for 'selectedAudioURL1'
}```


File 2 – PlayerPlaylistView:

TabBarButton(imageName: "Playlist", text: "Playlist", isSelected: selectedTab == "playlist")
.onTapGesture { selectedTab = "playlist" }
.background(
NavigationLink(
destination: PlaylistView(), // :red_exclamation_mark:Missing argument for 'selectedAudioURL1'
isActive: Binding(
get: { selectedTab == "playlist" },
set: { if !isActive { selectedTab = "home" } }
)
) { EmptyView() }.opacity(0)
)

Hi, Lahavta. This got flagged as being SwiftUI related, because normally we ask people to take questions about using Apple platform frameworks to the Apple developer forums. But in this case, I think you may just be misunderstanding the language a bit. PlaylistView seems to be your own type, and it sounds like its init has a selectedAudioURL1 argument. There's no special case here where bindings get magically added as call arguments; when you call an initializer, the arguments it gets are the arguments you pass.

3 Likes