0

Currently I am having issues passing data since I am assuming passing data through delegates require you to presentViewController

Currently I have something like this set up

GameViewController  *gameVC = [self.storyboard instantiateViewControllerWithIdentifier:@"GameViewController"];
gameVC.isTwoPlayer = isTwoPlayer;
gameVC.delegate = self;
[self presentViewController:gameVC animated:YES completion:nil];

So it's possible to sent data, but I have a navigation controller in between which I present modally story through board which has a relationship segue to GameViewController, which is why I can't presentViewController

I am wondering if it possible to sent data any other way

ZeMoon
  • 20,054
  • 5
  • 57
  • 98
PictureMeAndYou
  • 533
  • 2
  • 5
  • 16

1 Answers1

0

I am assuming passing data through delegates require you to presentViewController

Well, thats not true. You can pass data as long as the object is valid. The reason for calling presentViewController however is typically, when transition happens from one view controller to second view controller, you want some data to be passed to second view controller which could be displayed on new screen.

In fact, delegate pattern is not designed for passing data. It is meant to let one object do some activity on behalf of another. You pass data because you have an object of second VC created and it is nothing to do with delegation!

As far as passing data via other ways is concerned:

  1. Object Creation & Property Setting : Create object of class you want to pass data and set the properties on it.
  2. Singleton : Create a singleton object, set data and access it from anywhere.
  3. Core data : Use common tables for reading/writing. Typically you do this not just to share data but in situations that involve things like data massaging etc.
Abhinav
  • 37,684
  • 43
  • 191
  • 309