One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

RealityRenderer.EntityCollection

struct · iOS 18.0+ · SDK 27.1

@MainActor struct EntityCollection

A collection of entities in a ``RealityRenderer``. This collection is used by ``RealityRenderer/entities``.

Members (11)

method · iOS 18.0+

replaceAll

TypeScript
replaceAll(children: Array<Entity>): Promise<void>
Swift declaration
@MainActor mutating func replaceAll<S>(_ children: S) where S : Sequence, S.Element : Entity

Replaces all entities in this collection with those from the given sequence. - Parameters: - entities: The sequence of entities that will replace the collection's current contents. > Note: This operation might not maintain the new entities' index order.

get · iOS 18.0+

startIndex

TypeScript
get startIndex(): Promise<number>
Swift declaration
@MainActor var startIndex: Int { get }

The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.

get · iOS 18.0+

count

TypeScript
get count(): Promise<number>
Swift declaration
@MainActor var count: Int { get }

The number of elements in the collection. To check whether a collection is empty, use its `isEmpty` property instead of comparing `count` to zero. Unless the collection guarantees random-access performance, calculating `count` can be an O(*n*) operation. - Complexity: O(1) if the collection conforms to `RandomAccessCollection`; otherwise, O(*n*), where *n* is the length of the collection.

method · iOS 18.0+

index

TypeScript
index(i: number): Promise<number>
Swift declaration
@MainActor func index(after i: Int) -> Int

Returns the position immediately after the given index. The successor of an index must be well defined. For an index `i` into a collection `c`, calling `c.index(after: i)` returns the same index every time. - Parameter i: A valid index of the collection. `i` must be less than `endIndex`. - Returns: The index value immediately after `i`.

method · iOS 18.0+

append

TypeScript
append(sequence: Array<Entity>): Promise<void>
Swift declaration
@MainActor mutating func append<S>(contentsOf sequence: S) where S : Sequence, S.Element : Entity

Adds the specified sequence of entities to the end of this collection, in order. - Parameters: - sequence: The entities to add to the collection. > Note: This operation can invalidate the index order of any extant entities.

method · iOS 18.0+

insert

TypeScript
insert(sequence: Array<Entity>, index: number): Promise<void>
Swift declaration
@MainActor mutating func insert<S>(contentsOf sequence: S, beforeIndex index: Int) where S : Sequence, S.Element : Entity

Adds the specified sequence of entities to this collection in order, directly before the entity at the given index. - Parameters: - sequence: A sequence of entities to add to the collection. - index: The index of an entity to insert in front of. If `endIndex` is provided, the entities will be appended. > Note: This operation can invalidate the index order of any extant entities.

method · iOS 18.0+

remove

TypeScript
removeAt(index: number): Promise<void>
Swift declaration
@MainActor mutating func remove(at index: Int)

Removes the entity at the given index from this collection. - Parameters: - index: The index of the entity to remove from the collection. > Note: This operation can invalidate the index order of any remaining entities.

method · iOS 18.0+

remove

TypeScript
remove(child: Entity): Promise<void>
Swift declaration
@MainActor mutating func remove(_ child: Entity)

Removes the entity from the collection. - Parameters: - entity: The entity to remove from the collection. > Note: This operation can invalidate the index order of any remaining entities.

get · iOS 18.0+

endIndex

TypeScript
get endIndex(): Promise<number>
Swift declaration
@MainActor var endIndex: Int { get }

The collection's "past the end" position---that is, the position one greater than the last valid subscript argument. When you need a range that includes the last element of a collection, use the half-open range operator (`..<`) with `endIndex`. The `..<` operator creates a range that doesn't include the upper bound, so it's always safe to use with `endIndex`. For example: let numbers = [10, 20, 30, 40, 50] if let index = numbers.firstIndex(of: 30) { print(numbers[index ..< numbers.endIndex]) } // Prints "[30, 40, 50]" If the collection is empty, `endIndex` is equal to `startIndex`.

method · iOS 18.0+

removeAll

TypeScript
removeAll(): Promise<void>
Swift declaration
@MainActor mutating func removeAll()

Removes all entities from this collection.

subscript · iOS 18.0+

subscript

TypeScript
subscript(index: number): Promise<Entity>
Swift declaration
@MainActor subscript(index: Int) -> Entity { get }

Accesses the element at the specified position. The following example accesses an element of an array through its subscript to print its value: var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] print(streets[1]) // Prints "Bryant" You can subscript a collection with any valid index other than the collection's end index. The end index refers to the position one past the last element of a collection, so it doesn't correspond with an element. - Parameter position: The position of the element to access. `position` must be a valid index of the collection that is not equal to the `endIndex` property. - Complexity: O(1)

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →