I have 2 viewcontrollers, one displays the UI and the 2nd are settings. Im using the below code to save a segmented control button:
UserDefaults.standard.set(selectorLabel.selectedSegmentIndex, forKey: "stateSelected")
I then call it by:
if let value = UserDefaults.standard.value(forKey: "stateSelected"){
let selectedIndex = value as! Int
selectorLabel.selectedSegmentIndex = selectedIndex
}
This works as intended.
How would i save the actual title of each button press? For instance the one side of the control is labeled "LBs & INs" and the other "KGs & CMs". I want to save which one is selected. I then want to be able to use that saved text value on a label on the first viewcontroller when the view loads