解決:改變陣列對象從字符串到雙精度值,並且爲了做計算 由於
@IBAction func addNextPort(sender: UIBarButtonItem) {
if nextPortField.text == "" || milesNextField.text == "" || speedNextField.text == "" || pltOutNextField.text == "" || pltInNextField.text == "" || psNextField.text == "" {
var myAlert = UIAlertController(title: "Attenzione", message: "Tutti i campi sono obbligatori", preferredStyle: UIAlertControllerStyle.Alert)
myAlert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(myAlert, animated: true, completion: nil)
return
}
else {
var nextSpeddConv = NSString(string: speedNextField.text).doubleValue
var nextMlsConv = NSString(string: milesNextField.text).doubleValue
var nextHrsfunc = nextMlsConv/nextSpeddConv
var nextPltInConv = NSString(string: pltInNextField.text).doubleValue
var nextPsConv = NSString(string: psNextField.text).doubleValue
var nextPltOutConv = NSString(string: pltOutNextField.text).doubleValue
var addNext = NextModel(nextPort: nextPortField.text,
nextMls : "\(nextMlsConv)",
nextSpeed : "\(nextSpeddConv)",
nextHrs : "\(nextHrsfunc)",
nextEta : "\(nextHrsfunc)",
nextPltIn : "\(nextPltInConv)",
nextPs : "\(nextPsConv)",
nextPltOut : "\(nextPltOutConv)")
controller.next.append(addNext)
controller.salva()
controller.tableView.reloadData()
}
dismissViewControllerAnimated(true, completion: nil)
}
解決加入一些變種。謝謝 – 2014-10-10 05:55:15
解決:將字符串中的數組對象更改爲雙值 – 2014-10-12 14:50:32