I'm new in Swift, and i have an issue with error this class is not key value coding-compliant for the key.
I have reread all related topics and did not find a solution to this problem.
Please check out the code and give me some advice, what have I done wrong?
class FriendScore: NSObject {
var name:String?
var highestScore:Int?
}
var allScoresArr = [FriendScore]()
var dataArr = [[String:Any]]()
dataArr =[["name": "Ben", "highestScore": 15],["name": "Alex", "highestScore": 12]]
for user in dataArray {
if let dictionary = user as? [String:Any] {
let friendScore = FriendScore()
//Error Happens Here "Thread Breakpoint"
friendScore.setValuesForKeys(dictionary)
allScoresArr.append(friendScore)
}
}
print(allScoresArr)
The error:
<__lldb_expr_73.FriendScore 0x608000266080>
setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key highestScore.
'libc++abi.dylib: terminating with uncaught exception of type NSException