I have a segmented control, that change some calculations. When I had the control in the same VC as the rest of the app, it works, but I want to make a "settings page".
How can I make the selected state of the segmented control in "settingsVC" effect the "mainVC"?
From the "mainVC"
// Metric or imperial system segmented control
let argumentForSegment = metricImperialSegment.selectedSegmentIndex
if argumentForSegment == 0 {
statusLabel.text = "\(kmtLabel)"
topSpeedLabel.text = "\(topSpeedForLabel) kmh"
averageSpeedLabel.text = "\(averageSpeedForLabel) kmh"
altitudeLabel.text = "\(altitudeNoDecimals) m"
kmhMphLabel.text = "KMH"
}
if argumentForSegment == 1 {
statusLabel.text = "\(mphForLabel)"
From the "settingsVC"
import UIKit
let argumentForSegment = metricImperialSegment
class settingsVC: UIViewController {
@IBOutlet weak var metricImperialSegment: UISegmentedControl!
@IBAction func backButton(_ sender: Any) {
performSegue(withIdentifier: "toMainView", sender: self)
}
}