How can I "conditionally" join text from 2 or more textFields into a single textView ?
I cant seem to find a way to do this, is it even possible
(conditionally meaning - join only the text|Fields that have been selected by way of switches)
I am using userDefaults and iOS switches as shown in my below code.
ViewController2 (source)
let defaults = UserDefaults.standard
var switchON : Bool = false
@IBAction func checkState(_ sender: AnyObject) {
if Switch1.isOn{
switchON = true
defaults.set(switchON, forKey: "switch1ON")
}
if Switch1.isOn == false{
switchON = false
defaults.set(switchON, forKey: "switch1ON")
}
if Switch2.isOn{
switchON = true
defaults.set(switchON, forKey: "switch2ON")
}
if Switch2.isOn == false{
switchON = false
defaults.set(switchON, forKey: "switch2ON")
ViewController1 (destination)
override func viewDidLoad(){
super.viewDidLoad()
// Do any additional setup after loading the view.
// Select Comments -----------------------------------
if defaults.value(forKey: "switch1ON") != nil{
let switch1ON: Bool = defaults.value(forKey: "switch1ON") as! Bool
if switch1ON == true{
let userDefaults = UserDefaults.standard
Reference.text = userDefaults.value(forKey: "PredefinedText1") as? String
}
if defaults.value(forKey: "switch2ON") != nil{
let switch2ON: Bool = defaults.value(forKey: "switch2ON") as! Bool
if switch2ON == true{
let userDefaults = UserDefaults.standard
Reference.text = userDefaults.value(forKey: "PredefinedText2") as? String
}
// else if switch1ON == false{
// let userDefaults = UserDefaults.standard
// Reference.text = userDefaults.value(forKey: "") as? String
//}
}
}