'How do you handle dynamic column names in a SwiftUI Table on Mac

I have a SwiftUI table that I need to layout based on some request data from a server. This data is dynamic and changes. However, once I read this data into an array, it will not allow me to do a forEach on the column data, as it companies about not conforming to "TableColumnContent". Is there another way to loop this creation, or is there a simple way to conform to this protocol? I am having trouble understanding that protocol when I look at it.

struct DataProperty : Identifiable
{
    var id: String
    var name: String
}

struct TableDataView : View
{
    @EnvironmentObject var cache: ServerCache
    
    var body: some View
    {
        Table(cache.activeTableData)
        {
            ForEach(cache.activeProperties, id: \.self) {property in
                
                TableColumn(property.name, value: \.id)
                
            }
            
        }
    }
}

Note that activeProperties is an array of DataProperty. What am I doing wrong here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source