My AppEntity
has a Bool
property, and I would like to query by this property using EntityPropertyQuery
. I'm creating an EntityQueryProperty
for it with an EqualToComparator
as the following (partial code for brevity):
// My AppEntity
struct AlbumAppEntity: AppEntity, Identifiable {
@Property(title: "Hidden")
var isHidden: Bool
// Other properties
}
// My EntityPropertyQuery
static var properties = QueryProperties {
Property(\AlbumAppEntity.$isHidden) {
EqualToComparator { isHidden in
if isHidden {
return NSPredicate(format: "isHidden == YES")
} else {
return NSCompoundPredicate(type: .or, subpredicates: [NSPredicate(format: "isHidden = nil"), NSPredicate(format: "isHidden == NO")])
}
}
}
}
But the problem is that Shortcuts does not recognize it as a boolean parameter in the shortcuts editor. It recognizes it as a numeric field, which returns the error AppIntents.EntityPropertyQueryError error 2 when run:
I also tried different NSPredicate
, but the result is always the same:
Property(\AlbumAppEntity.$isHidden) {
EqualToComparator { NSPredicate(format: "isHidden == %d", $0) }
}
Property(\AlbumAppEntity.$isHidden) {
EqualToComparator { NSPredicate(format: "isHidden == %@", NSNumber(value: $0)) }
}
How can I query using boolean properties in a way that Shortcuts recognizes it and provides appropriate fields in the shortcuts editor?