if firstRandomNumber>secondRandomNumber{
playerscoretotal+=1
self.playerscore.text=String(playerscore)
}
Now
Could not find an overload for 'init' that acceptance the supplied arguments
The error appears.
Why?
I'm a beginner.
swift
Translating the error message freely
Playerscore type cannot be a String() argument
will be
If you want to focus only on the code presented away from the question, I think it's appropriate to rewrite it like this.
if firstRandomNumber>secondRandomNumber{
playerscoretotal+=1
self.playerscore.text=playerscore.description
}
Any type implementing the Printable
protocol must return some string (String type) and the description
must return.
The answer to the question is off the subject, but
playerscore.text
is substituted with playerscore
because of the error.
self.playerscore.text=String(playerscore)
The part of is
self.playerscore.text=String(playerscoretotal)
Isn't that what you are supposed to do?
I think that's all right.
self.playerscore.text="\"(playerscore)"
© 2024 OneMinuteCode. All rights reserved.