---
title: PlaygroundKeyValueStore
framework: playgroundsupport
role: symbol
role_heading: Class
path: playgroundsupport/playgroundkeyvaluestore
---

# PlaygroundKeyValueStore

A data storage container you use to persist information across different sessions.

## Declaration

```swift
class PlaygroundKeyValueStore
```

## Overview

Overview 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 }

## Topics

### Persisting Data

- [current](playgroundsupport/playgroundkeyvaluestore/3029533-current.md)
- [subscript(_:)](playgroundsupport/playgroundkeyvaluestore/3029534-subscript.md)

## See Also

### Data Persistence

- [PlaygroundValue](playgroundsupport/playgroundvalue.md)
- [playgroundSharedDataDirectory](playgroundsupport/playgroundshareddatadirectory.md)
