I have a Swift variable of type [String: AnyObject] however the function i'm trying to invoke requires a [String: Any] (This would be a Dictionary
fatal error: can't unsafeBitCast between types of different sizes
Any thoughts on what I should do in a situation like this?
Thanks!
This worked for me in a playground. Not sure it's the most efficient way, especially for a large dictionary, but it might work for your case.
var anyObjectDict = [String: AnyObject]()
anyObjectDict.updateValue("test", forKey: "key1")
anyObjectDict.updateValue(1.0, forKey: "key2")
var anyDict = [String: Any]()
for key in anyObjectDict.keys {
anyDict.updateValue(anyObjectDict[key], forKey: key)
}