Objective c 如何将字典从一个viewcontroller传递到另一个viewcontroller

Objective c 如何将字典从一个viewcontroller传递到另一个viewcontroller,objective-c,ios7,xcode5,uistoryboard,Objective C,Ios7,Xcode5,Uistoryboard,我有两个使用segue连接的视图控制器。如何将second viewcontroller中的一个字典{“fist”:1,“second”:2}传递给first viewcontroller。您必须在故事板中向segue添加标识符。 在您的源代码视图中,控制器覆盖prepareForSegue:方法: -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([segue.identifier isEq

我有两个使用segue连接的视图控制器。如何将second viewcontroller中的一个字典{“fist”:1,“second”:2}传递给first viewcontroller。

您必须在故事板中向segue添加标识符。 在您的源代码视图中,控制器覆盖prepareForSegue:方法:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([segue.identifier isEqualToString:@"YOURIDENTIFIER"]) { //<-YOURIDENTIFIER the same as you set up in storyboard

        UIViewController *vc = (UIViewController*)segue.destinationViewController;
        // You should cast destination view controller to your custom view controller sub class:
       //YourViewController *vc = (YourViewController*)segue.destinationViewController;
       // Pass the data
       vc.myDictionary = @{{"fist":1,"second":2};
       // I assume you have property myDictionary in YourViewController class
    }
}
-(void)prepareforsgue:(UIStoryboardSegue*)分段发送方:(id)发送方{

if([segue.identifier IsequalString:@“YOURIDENTIFIER”]){//我建议从阅读这个网站上已有的数百个问题的答案开始。如果这些答案对你不起作用,请解释你的情况有什么不同。在
prepareForSegue:
protocol中向上传递。我对iOS和objective c不熟悉。我已经尝试了一些可用的答案堆栈溢出。不幸的是,我没有得到输出。我试图从其他人那里得到一些帮助来解决我的问题,如果你愿意帮助我,就帮助我,否则就忽略它。谢谢你,格雷…它对我有用。你能标记为已回答,这样也许其他人会发现它有用。