Trying to overcome the 10 columns limit of Table in SwiftUI, I am trying to use Group to split the number of Views by group of 10. This generate a compiler error:
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
Here is the 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 ()
}
}
I tried to see if we can use the underlying protocols,... but this is too obscure for me, without an example at least.
It would be nice to have either an Apple statement stating that this is impossible so we do not spend time to try this route, or to have an little example
Many thanks for any help