ios - Is it possible to delegate without `presentViewController` -


this question has answer here:

currently having issues passing data since assuming passing data through delegates require presentviewcontroller

currently have 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 sent data, have navigation controller in between present modally story through board has relationship segue gameviewcontroller, why can't presentviewcontroller

i wondering if possible sent data other way

i assuming passing data through delegates require presentviewcontroller

well, thats not true. can pass data long object valid. reason calling presentviewcontroller typically, when transition happens 1 view controller second view controller, want data passed second view controller displayed on new screen.

in fact, delegate pattern not designed passing data. meant let 1 object activity on behalf of another. pass data because have object of second vc created , nothing delegation!

as far passing data via other ways concerned:

  1. object creation & property setting : create object of class want pass data , set properties on it.
  2. singleton : create singleton object, set data , access anywhere.
  3. core data : use common tables reading/writing. typically not share data in situations involve things data massaging etc.

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -