IPhone : EXC_BAD_INSTRUCTION runtime error when attempting to calculate

on Sunday, April 19, 2015

so im making a simple app to calculate simple values inputted by the user and some values already in the app but i keep getting this runtime error every time i try to calculate the result


here is the code:



for(var i = 0; i<name.count; i++){
if name[i] == typeFood{
yieldOutput == percent[i]
mycalc=percent[i] / 100.0
}
}

yieldOutput.text = String (format:"%.2f", percent )
var portionSize = typeDesired.text.toInt()! / typeOriginal.text.toInt()!
var myint:Int=typeAmount.text.toInt()!
var myres:Double=Double(myint)*(mycalc)*Double(portionSize)
amountOutput.text = String (format:"%.2f", myres)
self.typeDesired.resignFirstResponder()


i get the error on line



var myres:Double=Double(myint)*(mycalc)*Double(portionSize)

0 comments:

Post a Comment