Weird situation I've stumbled upon once upgrading to XCode 10.
I have an ObjectiveC class which I initialize in Swift. The initializer accepts NSDictionary as a parameter. If I pass in the dictionary directly into the initializer like so:
letcar = Car(parts: [myKey : myValue])
Then, back in ObjC world, when printing the contents of the dictionary it shows the value as "(null)".
The difference between the two invocations is whether we create a [String?: String] dictionary and convert it to [AnyHashable: Any], or whether we just start with [AnyHashable: Any] from the beginning. But they should indeed have the same observable behavior.
This is because Optional doesn't currently have a custom AnyHashable representation, making it incompatible with its wrapped values when converted to AnyHashable.
Attachment: Download
Environment
SwiftObjCPlay.zip
Additional Detail from JIRA
md5: 05dc781faf00fc6c7a8030c7994f7a76
Issue Description:
Weird situation I've stumbled upon once upgrading to XCode 10.
I have an ObjectiveC class which I initialize in Swift. The initializer accepts NSDictionary as a parameter. If I pass in the dictionary directly into the initializer like so:
Then, back in ObjC world, when printing the contents of the dictionary it shows the value as
"(null)"
.Everything works fine if I do:
This issue exists on any version of Swift on XCode 10. The issue doesn't exist on XCode 9.
I am attaching a sample project where this is illustrated.
The text was updated successfully, but these errors were encountered: