Subtracting inputed data in Swift -


good afternoon,

i having issue trying figure out how take data inputed textfield , use data later on in code. have attached code , able help.

@ibaction func wenter(sender: anyobject) {          let number1 = double(waisttext1?.text ?? "") ?? 0         let number2 = double(waisttext2?.text ?? "") ?? 0         let number3 = double(waisttext3?.text ?? "") ?? 0         let number4 = double(necktext1?.text ?? "") ?? 0         let number5 = double(necktext2?.text ?? "") ?? 0         let number6 = double(necktext3?.text ?? "") ?? 0         wavgtext.text = string(round(10 * (number1 + number2 + number3) / 3) / 10 ) + " inches"         navgtext.text = string((number4 + number5 + number6) / 3) + " inches"           let number7 = double(wavgtext.text! )         let number8 = double(navgtext.text! )          soldbf.text = string(number7 - number8) + "%"   } 

everything seems working correctly except when try subtract number7 number 8. missing something?

if need anymore details please let me know

it better if switch order of operations:

    let number7 = round(10 * (number1 + number2 + number3) / 3) / 10     let number8 = (number4 + number5 + number6) / 3      wavgtext.text = "\(number7) inches"     navgtext.text = "\(number8) inches"     soldbf.text   = "\(number7 - number8)%" 

then can see problem is.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -