SwiftData Expressions
SwiftData in iOS 18 supports predicate expressions, similar to Core Data's NSExpression.Predicate expressions allow for complex queries and calculations, using Foundation's #Expression macro.In Core Data, NSExpression allows for aggregate queries like finding minimum and maximum values.SwiftData's predicate expressions can evaluate arbitrary types as part of predicates.An example is finding items with at least two records with a score of 90 or more.SwiftData's predicate expressions use PredicateExpressions, which offer a range of methods.However, some methods, like finding maximum values, do not work consistently.SwiftData's predicate expressions currently provide limited advantages over direct predicate writing.The documentation for SwiftData's new features can be found on Apple's developer website.Future updates may improve the functionality of predicate expressions in SwiftData.