I have object like this:
class Human: NSObject {
var name:String!
var age:Int!
}
And make instance from object like this:
let instance = Human()
And set my values like this:
instance.name = "Kirk"
instance.age = 87
And print it like this:
print("name: \(instance.name)") // Kirk
print("age: \(instance.age)") //87
Every things are OK. but now set my values another way like this:
instance.setValue("Kirk", forKey: "name")
instance.setValue(87, forKey: "age")
Get this error for Int dataType:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key age.'
Why this happened?
And How to fix this because i need to using setValue() function.