I have the following code in the Playground:
class Pokemon : NSObject {
var name :String!
var id :Int?
var imageURL :String!
var latitude :Double!
var longitude :Double!
init(dictionary :[String:Any]) {
super.init()
setValuesForKeys(dictionary)
}
}
let dict :[String:Any] = ["name":"John","imageURL":"someimageURL","latitude":45.67]
let pokemon = Pokemon(dictionary: dict)
When the call to setValuesForKeys is made then it throws an exception saying the following:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__lldb_expr_13.Pokemon 0x6000000ffd00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key latitude.'
I have the key "latitude" but for some reason it is not able to find it. Any ideas!