Dynamically changing fetch request

Viewed 29

I have the below fetch request which I want to be able to dynamically change the setup of. The request is setup initially as

@SectionedFetchRequest(
    sectionIdentifier: \.level,
    sortDescriptors: [NSSortDescriptor(keyPath: \Card.level, ascending: true),
                      NSSortDescriptor(keyPath: \Card.setID, ascending: true),
                      NSSortDescriptor(keyPath: \Card.cardID, ascending: true),
                      NSSortDescriptor(keyPath: \Card.name, ascending: true)],
    animation: .default)
private var cards: SectionedFetchResults<Int16, Card>

I've got the predicate change working fine, and worked out the sort descriptors now, but can't work out how to change the section identifier, when I try I get the error

Cannot assign value of type 'SectionedFetchResults<String, Card>.Type' to type 'KeyPath<Card, Int16>'

I'm trying to change it using

cards.sectionIdentifier = SectionedFetchResults<String, Card>
0 Answers
Related