Does anyone now how I can fix the error "Fatal error: Unexpectedly found nil while unwrapping an Optional value"?
(And maybe what that means).
Thank you so much!
The error displays at the last line (19/20).
(And maybe what that means).
Thank you so much!
Code Block func updateUI() { var letters = [String]() for letter in currentGame.formattedWord { letters.append(String(letter)) } let wordWithSpacing = letters.joined(separator: " " ) correctWordLabel.text = currentGame.formattedWord scoreLabel.text = "Wins: \(totalWins), Losses: \(totalLosses)" treeImageView.image = UIImage(named: "Tree \(currentGame.incorrectMovesRemaining)") }
The error displays at the last line (19/20).
It means that something was nil where it should not be.what that means
Check all the place you use Implicitly Unwrapped Optional type (!) and forced unwrapping (!).how I can fix the error
In your code shown, there are no forced unwrappings, so you may have some properties with Implicitly Unwrapped Optional type.
I guess your treeImageView is declared as var treeImageView: UIImageView!, but it is not given a value.
If it is an @IBOutlet, check if it is properly connected in the storyboard.
One more, you need to check if you instantiated your view controller properly.