/StructPersistorSwiftPlayground

A simple play ground that describe the idea of persisting Struct in Swift.

Primary LanguageSwift

Struct Persistor Swift Playground

A simple playground that describe the idea of persisting Struct in Swift.

In the playground, I am showing how to take what used to be an object (a Player) in Objective-C and rewriting it as a stuct. We user the NSUserDefaults to store Player instance and this code also shows the changes we had to make to the underlying structure to be able to make it compliant to be saved to the defaults.

The specific features covered are:

  • Guard
  • FlatMap()
  • Protocols
  • Extensions