How to Access Objects from one ViewController to another ViewController

前端 未结 3 979
佛祖请我去吃肉
佛祖请我去吃肉 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:25

    viewControllers are a stack, so whichever one got called last is on top of the stack, and the one it got called from is its parent. So assuming viewController1 gets called first, and then viewController2 gets called from within that, then all you have to within viewController2.m is:

    [[self parentViewController] setString1:string2]
    

    :D

提交回复
热议问题