0

I have two View Controllers. First one have sendbutton that segue to second view controller. Action Segue is Show. Each time click the button, new window pops up again. I don't want create new window again, and I just want to only one second View Controller.

And my FirstViewController.m :

- (void)prepareForSegue:(NSStoryboardSegue*)segue sender:(id)sender{
        SecondViewController *destinationScene = [segue destinationController];
        destinationScene.receivedString = _nextOne.stringValue;
}

SecondViewController.m :

- (void)viewWillAppear{
        if(_myMutableArray == nil)  _myMutableArray = [NSMutableArray array];
        [_myMutableArray addObject:_receivedString];
}

What I want to is send a string in the first View Controller's TextField repeatedly to next View Controller. And keep using only one second window that created at first time.

See my Storyboard

2 Answers2

2

You can do this in IB without any code. Update the Presentation attribute for the view controller in the destination view from Multiple to Single:

https://stackoverflow.com/a/36104388/287963

Community
  • 1
  • 1
Jon
  • 1,469
  • 1
  • 14
  • 23
0

Don't set up the segue to happen automatically. Create an IBAction for the button, test whether your second view controller is already on the screen, and either segue or not depending on whether it already exists.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57