Quando vou compilar recebo o seguinte erro:
"libc++abi.dylib: terminating with uncaught exception of type NSException"
e o debug navigator, na parte de Thread1, me destaca a seguinte parte do AppDelegate.swift:
"class AppDelegate: UIResponder, UIApplicationDelegate{ "
Não sei o que está errado.
Meu código é:
Item.swift:
class Item {
let name:String
let calories:Double
init (name:String, calories:Double) {
self.calories = calories
self.name = name
}
}
Meal.swift:
class Meal {
let name:String
let happiness:Int
var Items:Array<Item> = []
init (name: String, happiness:Int) {
self.name = name
self.happiness = happiness
}
func allCalories() -> Double{
var total:Double = 0
for i in Items {
total += i.calories
}
return total
}
}
e o ViewControler.swift:
import UIKit
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.toInt()
if happiness == nil {
return
}
let meal = Meal(name: name, happiness: happiness!)
println("eaten: \(meal.name) \(meal.happiness)")
}
}
Não sei o que pode estar dando errado. Não consigo ir para frente