Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How to display the same total on two different view controllers

I am trying to display a total on the second page of my view controller in my app. The total displays the var totalPrice on the first page and I want it to display the same total for the variable purchaseTotal on the second view controller.

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var yesButton: UIButton!
@IBOutlet weak var noButton: UIButton!
@IBOutlet weak var purchaseButton: UIButton!
@IBOutlet weak var addJugButton: UIButton!
@IBOutlet weak var addSpeedButton: UIButton!
@IBOutlet weak var addReviveButton: UIButton!
@IBOutlet weak var addDoubleTapButton: UIButton!
@IBOutlet weak var totalPrice: UILabel!
@IBOutlet weak var purchaseTotal: UILabel!
var someValue: Double = 0.00 {
    didSet {
        totalPrice.text = "Total: $\(someValue)0"
    }

}


override func viewDidLoad() {
    super.viewDidLoad()

}
@IBAction func pressAddJugButton(_ sender: Any) {
    someValue += 2.50
}
@IBAction func pressAddSpeedButton(_ sender: Any) {
    someValue += 3.00
}
@IBAction func pressAddReviveButton(_ sender: Any) {
    someValue += 1.50
}
@IBAction func pressAddDoubleTapButton(_ sender: Any) {
    someValue += 2.00

} @IBAction func pressPurchaseButton(_ sender: Any) {

}




override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}

}