I wanted to use the .chunked function described in the article about Algorithms.
here is the code.
@Environment(\.managedObjectContext) private var viewContext
@Binding var tabSelection: Int
@FetchRequest(entity: Match.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Match.date, ascending: false)], animation: .default)
var matches: FetchedResults<Match>
// var key = "Show"
var match = [Match]()
var score = [Score]()
var scoresByBoard = [Score]()
var boardSet = [Score]() // subset of boards
@State var suitx = ["♣️", "♦️", "♥️", "♠️", "🚫"]
var body: some View {
List {
ForEach (matches, id: \.self) { match in
Section(header: Text(match.wrappedClub).headerStyle())
{
let tt = Int(match.maxPlayers)/4
let boardSets = match.scoreArray.chunks(ofCount: tt)
ForEach (boardSets, id: \.self) { score in
// for score in boardSets {
HStack {
Text(score.wrappedBoardNo)
Text(score.bidLevel ?? "?")
Text(suitx[Int(score.bidSuit ?? "0") ?? 0])
Text(score.bidBy ?? "?")
Text(score.bidMade ?? "?")
Text(score.bidDown ?? "?")
Text(score.nsScore.description)
Text(score.ewScore.description)
}
}
}
}
}.listStyle(.plain)// End List
/* .toolbar {
EditButton()
Button(action: addMatch) {
Label("Add Item", systemImage: "plus")
}
}
}
}
If I remove the / / around the additional Text fields, the errors generated will disappear, but when I try to build, I get an error at the view level that says the compiler can't check the code in a reasonable time, and try to break it up.
Not sure what to try next. Would appreciate any suggestions