HI everyone! I am really confused about this question , now i am parsing JSON file, by means of setValuesForKeys(:) function and everythink works fine, and i know setValuesForKeys(:) uses setValue(:forKey:) method for every property of my class. So when setValue(:forKey:) is called by setValuesForKeys(:), setValue(:forKey:) is searching for set() method to carrying out its task. And due to debug information i know that setValue(_:forKey:) is really founds this (set()) method! but i did not create it. So my question is , does swift (or objc) creates it is automatically or automatically during run time or anything else?
class Video: NSObject {
var thumbnail_image_name: String?
var title: String? var number_of_views: NSNumber?
var uploadDate: NSDate? var duration: NSNumber?
var channel: Channel?
override func setValue(_ value: Any?, forKey key: String) {
if key == "channel" { let channelDictionary = dictionary["channel"] as! [String: Any]
let channel = Channel()
channel.setValuesForKeys(channelDictionary) video.channel = channel }
else
{ super.setValue(value, forKey: key) }
}
}
class Channel: NSObject {
var name: String?
var profile_image_name: String?
}
https://stackoverflow.com/questions/46757955/is-swift-automatically-implementscreates-the-setter-setkey-method-for-se
here my question more concrete. Thanks for everyone I really confused((((