Passing data between two different storyboards

ios, segue, storyboard, xcode

Solution

1/ A good way to do this is to make a separate model object that can be equally addressed from both locations. And the simplest way to do that is to add a property to the `@interface` section of your `AppDelegate.h` file, eg

  @property (nonatomic, strong) NSString* sharedString;

To set and get it, you need to add typed access to the AppDelegate in any file that needs it:

  #include AppDelegate.h

Then you can use...

  AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];

  //to set (eg in A controller)
  appDelegate.sharedString = string;

  //to get (eg in B controller)
  NSString* string = appDelegate.sharedString;  

As an alternative to a property, you could use a static variable in a header file:

 static NSString* staticString;

Which would be accessible to any object that `#imports` the header file. Not really the Objective-C way though.

For more elaborate cases, you may want to create a singleton object to access your model data.

2/ Try:

  [self performSegueWithIdentifier: @"secondViewSegue" sender:self];

Ensure that the Segue is wired from your viewController, not it's Navigation Controller.

Problem

I have two questions. 1. First question: In my project, I have two different storyboard files: `A storyboard` and `B storyboard`. I want to pass data (`nsstring`) from `(A) controller of (A) storyboard` to `(B) controller of (B) storyboard` how I make it? 2. Second question: In the second storyboard, I have two controllers chained with a segue. When I call segue in the code with this instruction: ``` [self.navigation controller performSegueWithIdentifier: @"secondViewSegue" sender:self]; ``` I have a message: `"has no segue with identifier 'secondViewSegue' "` Why?

Original source