How to Access Objects from one ViewController to another ViewController

前端 未结 3 1247
故里飘歌
故里飘歌 2021-02-11 00:57

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:26

    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

提交回复
热议问题