NSUserDefaults does NOT persist data if used in a Swift playground

Originator:serieuxchat
Number:rdar://26942432 Date Originated:22-Jun-2016 03:37 PM
Status:Open Resolved:
Product:iOS SDK Product Version:Xcode 7.3.1 (7D1014)
Classification:Data Loss Reproducible:Always
 
Summary:
In a Swift playground I can retrieve the default instance of NSUserDefaults, but adding values to it has no effect.

Steps to Reproduce:
Create an iOS Swift playground and paste the following code into it:

let standardUserDefaults = NSUserDefaults.standardUserDefaults()
standardUserDefaults.setObject("TestString", forKey: "testKey")
standardUserDefaults.setInteger(10, forKey: "testInt")
standardUserDefaults.synchronize()
let defaultsDictionary = standardUserDefaults.dictionaryRepresentation()



Expected Results:
The dictionary representation should include the added string and integer.

Actual Results:
The NSUserDefaults dictionary representation is the same as initially, and no values have been added.

Version:
Xcode 7.3.1 (7D1014)

Notes:
If this feature is not supported, it must be clearly documented. But I could not find any references to playground in the documentation for NSUserDefaults.

Configuration:
OSX El Capitan, Xcode 7.3.1 (7D1014)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!