ios - Is it possible to delegate without `presentViewController` -
this question has answer here:
- passing data between view controllers 35 answers
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:
- object creation & property setting : create object of class want pass data , set properties on it.
- singleton : create singleton object, set data , access anywhere.
- core data : use common tables reading/writing. typically not share data in situations involve things data massaging etc.
Comments
Post a Comment