1 year ago
#212205
Rachel Rafik
Segue won't work to display text on a lavel
Okay, so I have two storyboards being incorporated into my code. One of them being the coffeeViewController, the other being the checkoutViewController. I have an array of doubles and different values incorporated into it. However, when I run the code, it shows the label that I want to edit as blank. Can someone tell me how to fix this?
This code is on my coffeeViewController
var total:[Double] = []
@IBAction func action(_ sender: Any) {
func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let sum = total.reduce(0,+)
let number = "\(sum)"
let lvc = segue.destination as! checkoutViewController
lvc.am = number
}
}
This code is on my checkoutViewController
var am = String()
override func viewDidLoad()
{
super.viewDidLoad()
amount.text = am
}
swift
uiviewcontroller
uistoryboardsegue
0 Answers
Your Answer