How To Get All Data From User Defaults

UserDefaults is a perfect place to keep configs of our app. It has a dictionary structure.

You can easily put some information into it.

let userDefaults = UserDefaults()
set(true, forKey: “Downloaded”)

It puts true value for key Downloaded.

To get this value you can use the same key.

userDefaults.bool(forKey: “Downloaded”)

It works easily. However, how to get all possible values?

To get all data use .dictionaryRepresentation().


It returns a dictionary with String as a key and Any as a value.

If you print that dictionary you’ll notice that there are more data than only what you saved.