0

I'm stuck trying to encode an array.

I have a class as following:

class EnemyMoveComponentSystem: GKComponentSystem<GKComponent> {

    func updateWithDeltaTime(seconds: TimeInterval, gameScene: GameScene) {

        for component in components {
            if let enemyMoveComponent = component as? EnemyMoveComponent {
                enemyMoveComponent.update(deltaTime: seconds, gameScene: gameScene)
            }
        }
    }
}

Then I declared an array as following:

var enemyMoveComponentSystems: [EnemyMoveComponentSystem] = []

However, when i tried to encode the array as below I get error:

override func encode(with aCoder: NSCoder) {
    aCoder.encode(enemyMoveComponentSystems, forKey: "Scene.enemyMoveComponentSystems")
}

Any help is appreciated.

0x141E
  • 12,613
  • 2
  • 41
  • 54
Bob
  • 155
  • 1
  • 8

0 Answers0