Development Blog (semi)random.thoughts()

January 2019

Loading and saving a game: GameplayKit and Codable protocol

GameplayKit is an Apple provided SDK that contains among others an easy-to-use Entity-Component system. I'm using it in a Roguelike I'm working on in my spare time, which I use to get a better grasp on developing in Swift.

While development in Swift with the Apple provided libraries is generally smooth sailing, getting saving and loading working was a lot more work. While most other features take me a few hours to implement, this one has taken days. This was mainly due to my lack of understanding of GameplayKit and (the limits) of protocol extension in particular. Because I could not found much (not enough for me?) information on this subject online, I'm sharing my experiences and solution here.

By no means is my solution the best, but at least it works. If you know of a better solution, the please let me know.

Read Moreā€¦

We value your privacy. This site collects only information required to provide you this Service. For more information, read our privacy policy.