Reputation: 306
Im new to swift and having a simple problem - I made the following class import Foundation
class UserIdWithScore: NSObject {
let userId: String
let score: String
init (userId: String, userScore: String) {
self.userId = userId
self.userScore = userScore
super.init()
}
then Im trying to make an instance of that class from another class
class otherClass : SimpleCommand
var usersIdAndScore = [UserIdWithScore()]
I get the following error - 'use of unresolved identifier 'UserIdWithScore' whats weird is that Xcode help me finish my line for UserIdWithScore .. Any suggestions?
Upvotes: 0
Views: 1041
Reputation: 31311
You don't have a default initializer in your class UserIdWithScore
. Instead you are initializing the class with two params (userId: String, userScore: String)
So call, var usersIdAndScore = [UserIdWithScore(userId: "userId_String", userScore: "userscore_string")]
or add the following initializer in your class
init() {
// perform some initialization here
}
Upvotes: 0
Reputation: 31016
Your initializer has two parameters. Try something like:
var usersIdAndScore = [UserIdWithScore(userId: "Me", userScore: "5")]
Or create an empty initializer that supplies default values.
Upvotes: 1