我有一个问题,我可以使用将所有数据传递给推送视图控制器
[self performSegueWithIdentifier:@"Expense" sender: self];
和
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
但是,当视图控制器弹出时,我不知道如何取回数据。我有几个数组需要从弹出的视图控制器传递到父视图控制器。
我有一个问题,我可以使用将所有数据传递给推送视图控制器
[self performSegueWithIdentifier:@"Expense" sender: self];
和
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
但是,当视图控制器弹出时,我不知道如何取回数据。我有几个数组需要从弹出的视图控制器传递到父视图控制器。
Create a class to serve as the data model for your application and have it include the arrays you need to pass around. Create an object of that class in your first controller, share it with the second controller during prepareForSegue:
, let the second controller update it, and read the new values when the parent's view appears again.
You should use segues to pass data forward and Delegate Methods to send data back in your navigation stack. That is the recommended approach. I answered a similar question earlier. Although the question may sound different, the underlying solution should work in your case as well.