The types you can save in the key-value store or send in messages to live views.


enum PlaygroundValue


The example below stores a dictionary in a PlaygroundValue instance and then stores the value in a PlaygroundKeyValueStore.

let myData = [
    "animal": PlaygroundValue.string("Llama"),
    "count": PlaygroundValue.integer(5)

PlaygroundKeyValueStore.current.keyValueStore["AnimalCountDict"] = .dictionary(myData)

For information about using PlaygroundValue instances to send messages, see Send and Receive Messages.


Representing Data

case boolean(Bool)

A value that represents a Boolean.

case data(Data)

A value that represents raw data.

case date(Date)

A value that represents a date.

case floatingPoint(Double)

A value that represents a floating-point number.

case integer(Int)

A value that represents an integer.

case string(String)

A value that represents a string.

Representing Data Collections

case array([PlaygroundValue])

A value that represents an array that contains PlaygroundValue instances.

case dictionary([String : PlaygroundValue])

A value that represents a mapping from strings to PlaygroundValue instances.

See Also

Data Persistence

class PlaygroundKeyValueStore

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

let playgroundSharedDataDirectory: URL

The path to the directory containing data shared between all playgrounds in Xcode.