I am attempting to show a segmented list for a CoreData fetchedResult:
struct ScanSummaryView: View {
let scans: FetchRequest<Scan>
init(showSentScans: Bool) {
scans = FetchRequest<Scan>(entity: Scan.entity(), sortDescriptors: [
NSSortDescriptor(keyPath: \Scan.category, ascending: true)
])
}
var body: some View {
NavigationView {
List {
ForEach(scans.wrappedValue) { scan in
Section(header: Text(scan.scanCategory)) {
ForEach(scan) { individual in
Text(scan.scanTitle)
}
}
}
}
}
}
}
But I receive the error
Cannot convert value of type 'FetchedResults.Element' (aka 'Scan') to expected argument type 'Range'
I am trying to group by scan.scanCategory and then show all the resulting scans grouped together.
What am I doing wrong? Thanks...