---
title: "addComponent(_:)"
framework: gameplaykit
role: symbol
role_heading: Instance Method
path: "gameplaykit/gkentity/addcomponent(_:)"
---

# addComponent(_:)

Adds a component to the entity.

## Declaration

```swift
func addComponent(_ component: GKComponent)
```

## Parameters

- `component`: An instance of a doc://com.apple.gameplaykit/documentation/GameplayKit/GKComponent subclass.

## Discussion

Discussion You create components by subclassing GKEntity to implement reusable behavior. Then, use this method to incorporate the behavior of a component class into that entity. An entity’s components list never has more than one instance of any component class—if the entity already contains a component of the same class as the component parameter, calling this method will replace that component.

## See Also

### Managing an Entity’s List of Components

- [components](gameplaykit/gkentity/components.md)
