ernestocattaneo ernestocattaneo - 5 months ago 22
Swift Question

How to print NSUserDefaults content in Swift

How do you print all the content of NSUserDefaults?
I need to see everything that has been stored into NSUserDefaults. Is there a simple way to print that or to see it into the logs?

In Swift!

Thank you

Answer

Adding more options:

For retrieving the complete dictionary representation of user defaults:

println(NSUserDefaults.standardUserDefaults().dictionaryRepresentation());

For retrieving the keys:

println(NSUserDefaults.standardUserDefaults().dictionaryRepresentation().keys.array);

For retrieving the values:

println(NSUserDefaults.standardUserDefaults().dictionaryRepresentation().values.array);