static func GetCardsToLearnPredicate() -> Predicate<Card> {
let todayMinus3Days: Date = Date.now.addDay(day: -3)
let todayMinus7Days: Date = Date.now.addDay(day: -7)
let todayMinus14Days: Date = Date.now.addDay(day: -14)
let todayMinus30Days: Date = Date.now.addDay(day: -30)
return #Predicate<Card> {card in
card.box == 1 || (card.box == 2 && card.lastStatusChange >= todayMinus3Days) || (card.box == 3 && card.lastStatusChange >= todayMinus7Days) || (card.box == 4 && card.lastStatusChange >= todayMinus14Days) || (card.box == 5 && card.lastStatusChange >= todayMinus30Days)
}
}
I get the error: “The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions”
That is where the predicate is used:
@Query(filter: Card.GetCardsToLearnPredicate())
var fetchedCards: [Card]
If I try to breaking it up into sub-expressions with some let’s then the compiler tells me, that a Predicate is only allowed to have one line of expression.
I already excluded the date manipulation because the compiler don’t get it inside of the predicate.
I don’t know what to do, also google doesn’t helped me out. It can’t be the truth that I can’t query data with only 1 or 2 expressions.
I’m new in the iOS swift field, was working c# for years and in the OR-Mappers I used there, that was no problem at all.