I'm a bit confused about what happens when downcasting NS… collections. I have this:
let jObject = try NSJSONSerialization.JSONObjectWithData (jsonData, options: NSJSONReadingOptions ())
which in this context is required to be a dictionary, so this is the way to downcast:
guard let jDictionary = jObject as? [String: AnyObject] else { return }
but I need to end up with a '[String: Any]' of "pure" Swift types, including Ints:
let properties: [String: Any] = jDictionary
What confuses me is that the values in jDictionary are AnyObject, so (I'd assume) any NSNumber values in the input stay as NSNumbers in jDictionary. But then, how do I get them bridged to Int in 'properties'? Do I have to iterate through the dictionary to force the bridging? Or are they automatically bridged in the last assignment?
Edit: The above compiled. Now that I try and run it, I get a crash with this message:
fatal error: can't unsafeBitCast between types of different sizes
which I don't exactly understand.