I can create every kind of predicates wonderful, however I am undecided what can I exploit for implement “ENDSWITH”?
extension Filter {
var predicate: Predicate<WordModel>? {
change self {
case .all:
.none
case .lettersContaining(let string):
#Predicate<WordModel> {
$0.letters.localizedStandardContains(string)
}
case .lettersStartingWith(let string):
#Predicate<WordModel> {
$0.letters.begins(with: string)
}
case .lettersEndingWith(let string):
#Predicate<WordModel> {
$0.letters.hasSuffix(string) // 🛑
}
}
}
}
This code says “The hasSuffix(_:) operate will not be supported on this predicate”.
I can see within the docs (at PredicateExpressions) that the predicate closure is a builder expression that may include a set set of expressions, I am simply undecided what to make use of for my use-case.
What do you utilize to create “ENDSWITH” predicates for a SwiftData @Question
?