CalcVC.mySales = Int(self.sales.text!)! / 109
CalcVC.myProfit = Int(self.profit.text!)! / 109.53
CalcVC.myPrice = Int(self.price.text!)!
CalcVC.myEPS = Double(self.eps.text!)!
Int(self.profit.text!)! / 109.53 とすると、エラーになるが、Int(self.profit.text!)! / 109に変えるとエラーが消える。為替の世界だと、109.00と109.53は全く違うので、Int(self.profit.text!)の方の型を変えないといけない。
あれ、さらにエラーが出た
Replace 'Double(self.sales.text!)! / 109.53' with 'Int(Double(self.sales.text!)! / 109.53)'
なるほど。受け取り側の型に合わせるのね。賢すぎ。
intでcastします。
if identifier == "showResult" {
let CalcVC = segue.destination as! CalcViewController
CalcVC.mySales = Int(Double(self.sales.text!)! / 109.53)
CalcVC.myProfit = Int(Double(self.profit.text!)! / 109.53)
CalcVC.myPrice = Int(self.price.text!)!
CalcVC.myEPS = Double(self.eps.text!)!
}
なるほど

109.53で割った数がintで表示されます。

ドル円の値をjsonで取得したい。(いよいよ趣旨に少しづつ近づいて来ました。)