Cannot roundtrip a Swift dictionary through NSPropertyListSerialization unless it contains an Int

Originator:eric.oconnell
Number:rdar://18191358 Date Originated:31/8/2014
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
 
Summary:
Creating a Swift Dictionary with only String values cannot be successfully passed through a call to NSPropertyListSerialization dataWithPropertyList:format:options:error: and propertyListWithData:options:format:error:, it will always yield this error:

Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format." (Unexpected character b at line 1) UserInfo=0x7ffaad30aba0 {NSDebugDescription=Unexpected character b at line 1, kCFPropertyListOldStyleParsingError=The data couldn’t be read because it isn’t in the correct format.}

Apparently, casting the Dictionary like so:
let plist: [NSString: NSObject] = [
        "a": "c",
        "b": "1"
    ]
will correct the issue.

Steps to Reproduce:
Paste attached code into a Swift playground.

Expected Results:
The code will print "heyo".

Actual Results:
The code prints "laaaame" because the plist deserialization fails.

Version:
XCode 6 beta 6 6A280e
OS X Mavericks 13E28

Notes:
Someone on irc confirmed this on their box, and suggested the casting fix.

Configuration:
Configuration is (seemingly?) irrelevant

Attachments:
'plist-serialization-weirdness.swift' was successfully uploaded.

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!