I have not studied iOS or Swift for a very long time. With one of the latest Xcode updates, many of the applications I have made on my computer now use outdated syntax.
Xcode tells us converting it to a new syntax, but often it doesnβt solve anything, and I have a new problem. Here is the code for one of the first applications I made after syntax conversion. I get an error message:
The value of the optional type 'String?' does not unfold; you wanted to use '!' or '?'
I know this should be very simple, but I donβt know how to fix it. Here is my code:
@IBAction func findAge(sender: AnyObject) { var enteredAge = Int(age.text) if enteredAge != nil { var catYears = enteredAge! * 7 resultLabel.text = "Your cat is \(catYears) in cat years" } else { resultLabel.text = "Please enter a whole number" } }
source share