0

I have two view controllers in my project that one of them has a label with text - I want to have first view controller labeltext in the second view controller

here is first view controller codes :

    @IBOutlet weak var customKind: UILabel!

     override func viewDidLoad() {
        super.viewDidLoad()

          customKind.text = "Custom"
         }

and here is my second view controller codes :

@IBOutlet weak var customType: UILabel!
 override func viewDidLoad() {
    super.viewDidLoad()

    customType.text = firstLevelViewController().customKind.text

    }

I can't access this information in my second view controller please help me to do that

**Remember That These View Controller Are not Connected to each Other And I want to access their Information Without Connecting **

Saeed Rahmatolahi
  • 1,317
  • 2
  • 27
  • 60

1 Answers1

0

This thread Passing Data between View Controllers covers most of what you need for passing data between View Controllers. If your two view controllers have a common root then you can pass data up the hierarchy from view controller one and then back down to view controller two.

If your view controllers are so separated then you should consider storing your data in a class separate from your view controller hierarchy. Or you could make view controller two as a delegate of view controller one. See the section of the thread I linked to about delegates and protocols.

Community
  • 1
  • 1
adamfowlerphoto
  • 2,708
  • 1
  • 11
  • 24