QueryPredicate
struct · iOS 15.0+ · SDK 27.1
struct QueryPredicate<Value>An object that defines the criteria for an entity query. Query predicates specify the entities an ``EntityQuery`` returns from a scene. Predicates describe entities based on which components they contain, or on the entity’s relationship to other entities in the scene. For example, you can build a predicate to retrieve the model entities from a scene. ```swift let modelPredicate = QueryPredicate.has(ModelComponent.self) ``` ### Create compound predicates You can combine predicates using Swift’s logical operators to create compound predicates. ``QueryPredicate`` supports Swift’s logical `AND` (`&&`), logical `OR` (`||`), and logical `NOT` (`!`) operators. The following code shows how to build a compound predicate that returns all entities that are either model entities or anchor entities: ```swift let orPredicate: QueryPredicate<Entity> = .has(ModelComponent.self) || .has(AnchorComponent.self) ``` Use parentheses to control the order of operations when combining predicates. For example, you can create a query that returns any entity that has both a model component and a physics body component, or any entity that has only an anchor component. ```swift let multiPredicate: QueryPredicate<Entity> = .has(ModelComponent.self) && .has(PhysicsBodyComponent.self) || .has(AnchorComponent.self) ```
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
QueryPredicate.has(_:)
Passing a Swift type itself is not supported.