I have an class (model) written in Swift and I want to access it from Objective C class, but I can't.
To explain more, I have an array which is getting appended with dictionaries from that model written in Swift.
Model looks like this:
@objc class GoalPreviewModel: NSObject {
var id : Int?
var name : String?
init(dictionary: NSDictionary) {
self.id = dictionary["id"] as? Int
self.name = dictionary["name"] as? String
}
}
This dictionary is filled fine by this model and everything works fine as long I'm accessing it from class written in Swift. The problem occurs when I try to access that array of dictionaries and access the properties. The statement bellow is working fine when I want to access name.
[_nameLabel setText:[(NSString*) [[AppState sharedInstance].arrayOfDicts objectAtIndex:idx] valueForKey:@"name"]];
But when I try to access valueForKey:@"id" it gives me an error like this "this class is not key value coding-compliant for the key id."
Can somebody help me out on this?
Thanks in advance!