I’m trying to use the new Table view in SwiftUI for iOS 16 to display a list of people with columns for their given name, family name, and email address. According to Apple’s documentation, Table should be available on iOS 16, but I’m encountering an error that says:
Argument type '[Person]' does not conform to expected type 'Decoder'
Here’s the code I am using:
struct Person: Identifiable {
let givenName: String
let familyName: String
let emailAddress: String
let id = UUID()
var fullName: String { givenName + " " + familyName }
}
struct PeopleTable: View {
@State private var people = [
Person(givenName: "Juan", familyName: "Chavez", emailAddress: "[email protected]"),
Person(givenName: "Mei", familyName: "Chen", emailAddress: "[email protected]"),
Person(givenName: "Tom", familyName: "Clark", emailAddress: "[email protected]"),
Person(givenName: "Gita", familyName: "Kumar", emailAddress: "[email protected]")
]
var body: some View {
Table(people) {
TableColumn("Given Name", value: .givenName)
TableColumn("Family Name", value: .familyName)
TableColumn("E-Mail Address", value: .emailAddress)
}
}
}
I’ve confirmed that:
- My deployment target is set to iOS 17.
- I’m using Xcode 15.4.
- The List works without any issues in place of Table.
Is there something I’m missing in the configuration, or is this a bug with SwiftUI’s Table on iOS? Has anyone successfully used Table in iOS 16?
Any help or insight would be greatly appreciated!
10