Hi Folks,
Sorry I am sure this has been asked before - Beginner level programmer trying to get my head round something I am sure is simple. I know coredata is not a Relational database but please go easy!!
I have data my app is storing as people respond to the 'game'
a 'session' guid (runNumber) , and if they hit the correct button or not (correctAnswer). I want to group the responses by the guid and sum the 'correct' answers.
I think I am pulling the data correctly:
@Environment(\.managedObjectContext) private var viewContext
@FetchRequest(
entity: CoreScore.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \CoreScore.runNumber, ascending: false)
]
) var corescores: FetchedResults<CoreScore>
But my view
List(corescores, id: \.self) { corescore in
Text(corescore.runNumber ?? "Unknown")
Text(corescore.correctAnswer ?? "Unknown")
}
Shows all the individual responses...
How do I group them by runNumber?
Sorry I am sure this has been asked before - Beginner level programmer trying to get my head round something I am sure is simple. I know coredata is not a Relational database but please go easy!!
I have data my app is storing as people respond to the 'game'
a 'session' guid (runNumber) , and if they hit the correct button or not (correctAnswer). I want to group the responses by the guid and sum the 'correct' answers.
I think I am pulling the data correctly:
@Environment(\.managedObjectContext) private var viewContext
@FetchRequest(
entity: CoreScore.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \CoreScore.runNumber, ascending: false)
]
) var corescores: FetchedResults<CoreScore>
But my view
List(corescores, id: \.self) { corescore in
Text(corescore.runNumber ?? "Unknown")
Text(corescore.correctAnswer ?? "Unknown")
}
Shows all the individual responses...
How do I group them by runNumber?