<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKComponent"
  },
  "title" : "GKComponent"
}
-->

# GKComponent

The abstract superclass for creating objects that add specific gameplay functionality to an entity.

```
class GKComponent
```

## Overview

[`GKComponent`](/documentation/GameplayKit/GKComponent) is the abstract superclass for custom component classes you create when building a game with Entity-Component architecture. In this architecture, an *entity* is an object relevant to the game, and a *component* is an object that handles specific aspects of an entity’s behavior in a general way. Because a component’s scope of functionality is limited, you can reuse the same component class for many different kinds of entities.

You create components by subclassing [`GKComponent`](/documentation/GameplayKit/GKComponent) to implement reusable behavior. Then, you build game entities by creating [`GKEntity`](/documentation/GameplayKit/GKEntity) objects and using the [`addComponent(_:)`](/documentation/GameplayKit/GKEntity/addComponent(_:)) method to attach instances of your custom component classes.

At runtime, a component-based game needs to dispatch periodic logic—from an update/render loop method such as <doc://com.apple.documentation/documentation/SpriteKit/SKScene/update(_:)> (SpriteKit) or <doc://com.apple.documentation/documentation/SceneKit/SCNSceneRendererDelegate/renderer(_:updateAtTime:)> (SceneKit), or a <doc://com.apple.documentation/documentation/QuartzCore/CADisplayLink> (iOS) or <doc://com.apple.documentation/documentation/CoreVideo/CVDisplayLink> (macOS) timer in a custom rendering engine—to each of its components. GameplayKit provides two mechanisms for dispatching updates:

- Per-entity. Call each entity’s [`update(deltaTime:)`](/documentation/GameplayKit/GKEntity/update(deltaTime:)) method, which will then forward to the [`update(deltaTime:)`](/documentation/GameplayKit/GKComponent/update(deltaTime:)) method of each component. This option can be quickly implemented in games with a small number of entities and components.
- Per-component. Use a [`GKComponentSystem`](/documentation/GameplayKit/GKComponentSystem) object to handle all instances of a specific component class. When you call a component system’s [`update(deltaTime:)`](/documentation/GameplayKit/GKComponentSystem/update(deltaTime:)) method, it forwards to the [`update(deltaTime:)`](/documentation/GameplayKit/GKComponent/update(deltaTime:)) method of all the component objects it manages. Because a component system needs no knowledge of your game’s entity/component hierarchy, this option works well for games with complex object graphs.

For more information on Entity-Component architecture, read [Entities and Components](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/EntityComponent.html#//apple_ref/doc/uid/TP40015172-CH6) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Performing Periodic Updates

[`-  updateWithDeltaTime:`](/documentation/GameplayKit/GKComponent/update(deltaTime:))

Performs any custom periodic actions defined by the component subclass.

### Working with Entities

[`entity`](/documentation/GameplayKit/GKComponent/entity)

The entity that owns this component.

[`-  didAddToEntity`](/documentation/GameplayKit/GKComponent/didAddToEntity())

Notifies the component that it has been assigned to an entity.

[`-  willRemoveFromEntity`](/documentation/GameplayKit/GKComponent/willRemoveFromEntity())

Notifies the component that it has been removed from an entity.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCopying`](/documentation/Foundation/NSCopying)

### Inherited By

[`GKSKNodeComponent`](/documentation/GameplayKit/GKSKNodeComponent)

[`GKAgent`](/documentation/GameplayKit/GKAgent)

[`GKSCNNodeComponent`](/documentation/GameplayKit/GKSCNNodeComponent)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)