---
title: GKComponentSystem
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkcomponentsystem
---

# GKComponentSystem

Manages periodic update messages for all component objects of a specified class.

## Declaration

```swift
class GKComponentSystem<ComponentType> where ComponentType : GKComponent
```

## Overview

Overview A GKComponentSystem object manages periodic update messages for components in a game that uses Entity-Component architecture. Use a component system to perform per-frame logic for all components of a specific class without traversing your game’s object hierarchy to dispatch update messages. Each GKComponentSystem object manages components of a specific GKComponent subclass. You create a component system with the init(componentClass:) initializer, specifying the component class it will work with. Then, you register the components used by the entities in your game with the addComponent(_:) or addComponent(foundIn:) methods. The component system will then forward any component-specific messages it receives to all registered instances of its component class. The most important of the component-specific messages is the update(deltaTime:) method. Call this method from your game’s update/render loop—that is, from a method such as update(_:) (SpriteKit) or renderer(_:updateAtTime:) (SceneKit), or from a CADisplayLink (iOS) or CVDisplayLink (macOS) timer in a custom rendering engine. The component system then forwards to the update(deltaTime:) method of all the GKComponent subclass instances it manages, allowing those objects to perform per-frame update logic. For more information on Entity-Component architecture, read Entities and Components in GameplayKit Programming Guide.

## Topics

### Creating a Component System

- [init(componentClass:)](gameplaykit/gkcomponentsystem/init(componentclass:).md)

### Managing a List of Components

- [componentClass](gameplaykit/gkcomponentsystem/componentclass.md)
- [components](gameplaykit/gkcomponentsystem/components.md)
- [addComponent(_:)](gameplaykit/gkcomponentsystem/addcomponent(_:).md)
- [addComponent(foundIn:)](gameplaykit/gkcomponentsystem/addcomponent(foundin:).md)
- [removeComponent(_:)](gameplaykit/gkcomponentsystem/removecomponent(_:).md)
- [removeComponent(foundIn:)](gameplaykit/gkcomponentsystem/removecomponent(foundin:).md)

### Performing Periodic Updates

- [update(deltaTime:)](gameplaykit/gkcomponentsystem/update(deltatime:).md)

### Accessing Components With Subscript Syntax

- [subscript(_:)](gameplaykit/gkcomponentsystem/subscript(_:).md)

### Instance Methods

- [classForGenericArgument(at:)](gameplaykit/gkcomponentsystem/classforgenericargument(at:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSFastEnumeration](foundation/nsfastenumeration.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Entities and Components

- [GKEntity](gameplaykit/gkentity.md)
- [GKComponent](gameplaykit/gkcomponent.md)
