SwiftData has revamped the mechanism for creating data models, incorporating a type-safe mode for predicate creation based on model code. As a result, developers encounter numerous operations involving optional values when constructing predicates for SwiftData. This article will explore some techniques and considerations for handling optional values while building predicates.
From "Inside-Out" to "Outside-In" Transformation
Among the many innovations in SwiftData, the most striking is allowing developers to declare data models directly through code. In Core Data, developers must first create a data model in Xcode's model editor (corresponding to NSManagedObjectModel) before writing or auto-generating NSManagedObject subclass code.