1
I have the following problem:
Value of type 'String? ' has on Member 'Int'
What is the reason for the error and what is the solution?
class ViewController: UIViewController {
@IBOutlet var nameField: UITextField!
@IBOutlet var happinessField: UITextField!
@IBAction func add() {
if nameField == nil || happinessField == nil {
return
}
let name = nameField!.text
let happiness = happinessField!.text.Int() // Erro aqui
if happiness == nil {
return }
let meal = Meal(name: name!, happiness: happiness!)
print("eaten: \(meal.name) \(meal.happiness)")
}
}
That was in Swift 1.0 I think
– leofontes