I have the below fetch request which I want to be able to dynamically change the setup of.
The request is setup initially as
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, but get errors with the sort descriptors and the section identifier
On setting the sort descriptors I get the error
Cannot convert value of type 'NSSortDescriptor' to expected element type 'Array<SortDescriptor>.ArrayLiteralElement' (aka 'SortDescriptor')
And setting the section identifier I get
Cannot assign value of type 'SectionedFetchResults<String, Card>.Type' to type 'KeyPath<Card, Int16>'
The code I have is below.
if groupBy == 2 {
cards.nsPredicate = nil
let sortSetID = NSSortDescriptor(keyPath: \Card.setID, ascending: true)
let sortName = NSSortDescriptor(keyPath: \Card.name, ascending: true)
cards.sortDescriptors = [sortSetID, sortName] // This errors
cards.sectionIdentifier = SectionedFetchResults<String, Card> // This errors
}