Monday, September 30, 2024

SwiftData Expressions

Keith Harrison:

In iOS 18, SwiftData can make use of Foundation’s new #Expression macro to make it easier to build more complex predicates. From the WWDC session:

Expressions allow for reference values that do not produce true or false but instead allow for arbitrary types.

You can then evaluate the expression as part of more complex predicate.

[…]

If you expand the expression macro or check the Expression documentation you’ll see it’s creating PredicateExpressions which appear to support a wide range of methods. Unfortunately I can’t seem to get most of them to work either in predicates or expressions.

Previously:

Comments RSS · Twitter · Mastodon

Leave a Comment