Friday, May 20, 2022
HomeiOS Developmentios - Accessing knowledge from totally different screens - swift

ios – Accessing knowledge from totally different screens – swift


I’m making an attempt to get knowledge from a special display however for some purpose, the variable doesn’t replace. right here is the code up to now

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let viewController: UIViewController = UIViewController()

        change (indexPath.row) {
               case 0:
                   print("hi there")
                let vc = AddViewController()
                vc.chosenDaily = true
                dismiss(animated: true, completion: nil) 

right here I created a tableView and as soon as the consumer clicks on the primary index of my tableView I need to set a boolean variable to true and return to a different display. I declared this boolean variable on the opposite display right here.

    var chosenDaily:Bool = false

on the identical display, I’ve a save button and need to print the end result.

@IBAction func didTapSaveButton() {
        
        
        
        if chosenDaily == true {
            print("it is true")
        } else if chosenDaily == false {
            print("it is false")
        }
}

however for some purpose, the code does not replace and returns false as a substitute of true. can anybody assist? thanks for any assist that i get

RELATED ARTICLES

Most Popular

Recent Comments