Instance Method

componentForClass:

Returns the entity’s component for the specified component class.

Declaration

- (GKComponent *)componentForClass:(Class)componentClass;

Parameters

componentClass

The GKComponent subclass for which to return a component instance.

Return Value

The component instance for the specified class, or nil if the entity has no components of that class.

Discussion

An entity’s components list always has no more than one instance of any component class. Use this method to retrieve a component instance when all you know is that the entity contains a component of a particular class.

See Also

Managing an Entity’s List of Components

components

The entity’s list of components.

- addComponent:

Adds a component to the entity.

- removeComponentForClass:

Removes the component of the specified class from the entity.