I am attempting to overcome the 10 columns limitation of Table This is "Crashing" the compiler with this error:
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
Code:
import SwiftUI
//---------------------------------------------------------------------------------------------
struct TestStruct : Identifiable
{
var id = UUID ()
var name : String
var val : Int
}
//---------------------------------------------------------------------------------------------
struct ContentView: View
{
@State var testData : [ TestStruct ] = [ TestStruct ( name: "Leopold", val: 1 ), TestStruct ( name: "Napoleon", val: 2 ) ]
var body: some View
{
VStack
{
Table ( testData )
{
Group
{
TableColumn ( "Name" ) { testStruct in Text ( testStruct.name ) }
TableColumn ( "Value" ) { testStruct in Text ( String ( testStruct.val ) ) }
}
}
}
}
}
//---------------------------------------------------------------------------------------------
struct ContentView_Previews: PreviewProvider
{
static var previews: some View
{
ContentView ()
}
}
Can Apple provide a working example with more than 10 columns ( e.g: using a ForEach ... ) , that would be perfect
Many thanks