PlaygroundKeyValueStore
A data storage container you use to persist information across different sessions.
Declaration
class PlaygroundKeyValueStoreOverview
The key-value store is available only in Swift Playgrounds and is persistent only in playground books.
The example below sets the value of the key “animal” in the playground key-value store to “Llama” and then retrieves the value of that key back from the key-value store.
// Store a value.
PlaygroundKeyValueStore.current.keyValueStore["animal"] = .string("Llama")
// Retreive that same value.
var theAnimal: String? = nil
if let keyValue = PlaygroundKeyValueStore.current.keyValueStore["animal"],
case .string(let animalType) = keyValue {
theAnimal = animalType
}