SwiftUI Beta 4 'identified(by:)' is deprecated:

/Users/hcri50/Documents/SwiftUI/DeleteUser/DeleteUser/ContentView.swift:17:35: ‘identified(by:)’ is deprecated: Use ForEach(:id:) or List(:id:).
I have tried
ForEach(users:id(by: .self))
ForEach(users.:id:(by: .self))
And nothing is working.
Can someone please point me in the right direction please

My code below

struct ContentView : View {
@State var users = [“Paul”, “Taylor”, “Adele”]

var body: some View {
        NavigationView {

            List {
                ForEach(users.identified(by: \.self)) { user in
                    Text(user)
                }
                .onDelete(perform: delete)
            }
        }
    }

func delete(at offsets: IndexSet) {
if let first = offsets.first {
users.remove(at: first)
}
}
}

Hi @hcri1950, what about trying

ForEach(users, id: \.id) 

Best,
Gina

1 Like

Thank you for I can not believe that I did not try that. Sorry I could not reply sooner for I was traveling. And then last night I downloaded and installed Beta 5 and it stated that I was missing a plug-in. Only to find out on the developers site that other developers were receiving the same message. I am now at the office and I will continue with Beta 4 THANK YOU VERY VERY MUCH.
01%20PM|418x192

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.