The code below works in Xcode 9.2 (Swift 4.0) but gives an error in Xcode 9.3 (Swift 4.1).
let dict: [String: Any] = [
"status_code": 5,
"status_message": "message"
]
let data = try! JSONEncoder().encode(dict)
// ^ generic parameter 'T' could not be inferred
I've tried making the dictionary [String: Encodable]
, and using a typealias
to both dictionary types, with the same results. Swift doesn't let you specify the type in a generic call, so that gives a compiler error. What should this look like in Swift 4.1?