How to Access Objects from one ViewController to another ViewController

前端 未结 3 983
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-11 00:50

Provide some tips to get rid of the following scenario.

Description:

I have two viewControllers namely ViewController1 and ViewController2, so

3条回答
  •  悲&欢浪女
    2021-02-11 01:15

    You can use a model object that contains the two strings and that is known by both controllers.

    If you want each controller to be notified whenever the other update the value of the strings, you can use notification mechanism. This allows your model to let other objects know about its changes and stay independant from these objects.

提交回复
热议问题