I’m trying to use a Decimal
as a @Property
in my AppEntity
, but using the following code shows me a compiler error. I’m using Xcode 16.1.
The documentation notes the following:
You can use the @Parameter property wrapper with common Swift and Foundation types:
- Primitives such as Bool, Int, Double, String, Duration, Date, Decimal, Measurement, and URL.
- Collections such as Array and Set. Make sure the collection’s elements are of a type that’s compatible with IntentParameter.
Everything works fine for other primitives as bools, strings and integers. How do I use the Decimal
though?
Code
struct MyEntity: AppEntity {
var id: UUID
@Property(title: "Amount")
var amount: Decimal
// …
}
Compiler Error
This error appears at the line of the @Property
definition:
Generic class 'EntityProperty' requires that 'Decimal' conform to '_IntentValue'
Hi @alexander216,
The documentation notes the following:
You can use the @Parameter property wrapper with common Swift and Foundation types:
- Primitives such as Bool, Int, Double, String, Duration, Date, Decimal, Measurement, and URL.
- Collections such as Array and Set. Make sure the collection’s elements are of a type that’s compatible with IntentParameter.
Please note that the linked documentation describes the @Parameter
property wrapper, not the @Property
wrapper. I can see how that could cause confusion at a glance.
Best,
-J