How to define a generic SwiftUI view that can accept sectioned fetch results for different entities

I need to define a generic SwiftUI view that can accept sectioned fetch results for different CoreData entities, but I'm not sure how to define the generic view.

In the example below, I have two sectioned fetch results defined for Patient and Doctor entities. I need to be able to pass them to the generic view.

@SectionedFetchRequest(
    sectionIdentifier: \.sectionTitle,
    sortDescriptors: Patient.nameSortDescriptors(), animation: .default)
private var patients: SectionedFetchResults<String, Patient>

@SectionedFetchRequest(
    sectionIdentifier: \.sectionTitle,
    sortDescriptors: Doctor.nameSortDescriptors(), animation: .default)
private var doctors: SectionedFetchResults<String, Doctor>

GenericView(items: patients)
GenericView(items: doctors)

struct GenericView: View {
    let items: ?????
}
Answered by LowRight in 704483022

What are the similarities between Patient and Doctor that lead you to believe you should be using generics? What should the content of GenericView be if the fetch results are Patient vs Doctor? You should start by creating two separate concrete implementations of GenericView for each type of fetch result.

Accepted Answer
How to define a generic SwiftUI view that can accept sectioned fetch results for different entities
 
 
Q