IOS + Swift Swift 5
Swift – How to let users delete rows from a list
May 9, 2021
0

struct MainView: View {

  @State private var users = [“ZERIN”, “ARIF”, “TIKLU”]

    var body: some View {

        NavigationView {

            List {

                ForEach(users, id: \.self) {

                    user in Text(user)

                }

            .onDelete(perform: delete)

            }

        }

    }

    func delete(at offsets: IndexSet) { users.remove(atOffsets: offsets) }

}

   

About author

ZERIN

CEO & Founder (BdBooking.com - Online Hotel Booking System), CEO & Founder (TaskGum.com - Task Managment Software), CEO & Founder (InnKeyPro.com - Hotel ERP), Software Engineer & Solution Architect

Swift – Add Sections to List

struct Pizzeria: View {     let name: String   ...

Read more

Swift – Carousel Lists on watchOS

List(1..<51) { Text("\($0)") } .listStyle(Carou...

Read more

Swift – create expanding lists

// //  MainView.swift //  MySwiftLearning1 // //...

Read more

There are 0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *