I'm converting a project that previously stored some NSPredicates
as the string format. When converting to SwiftData I discovered Predicate is Codable
, which makes things nice... except for PredicateCodableConfiguration
.
From what I understand you have to specify every model and key you use in the predicate or the encode/decode fails.
This is kind of a pain, because you already define this in the Predicate
. Does anyone know what the reason for this is?
There's also PredicateCodableKeyPathProviding
which lets you define the keys for a class all at once, which makes it slightly easier.
But if SwiftData is intended to reduce boilerplate code, why does the Predicate
itself not provide enough detail about what to encode/decode?