Latest Post

Dependency injection in swift SwiftUI interview questions and answer How to display SwiftUI sheet Half screen
selection list of  Particular Row in SwiftUI. Swift Supports both single selection and as well as multiple Selection in List.Swiftui list Selection

Earlier we used to have tableView DidSelect method in Storyboard but now we have list we can add selection of row in Swift.

Swiftui list Selection

To create a Single selection in SwiftUI we needed to declare the variable as vehicleSelected as shown in below code

struct ContentView: View {

    let vehicles = [






    @State private var vehicleSelected: String?

    var body: some View {

        NavigationView {

            List(vehicles, id: .self, selection: $vehicleSelected) { vehicle in



            .navigationTitle("Vehicle Selection")

            .toolbar {






we can select the multiple row by changing the type of vehicleSelected by using Set

@State private var selection = Set<String>()