ios - dismissViewControllerAnimated not passing back data to vc1 -


i have vc1 , vc2. need vc2 set vc1's variable when vc2 dismissed.

this relevant code in vc1.h

- (ibaction)btnclick:(id)sender; @property (strong, nonatomic) nsstring *mystr; 

this relevant code in vc1.m

- (ibaction)btnclick:(id)sender {     uistoryboard * storyboard = self.storyboard;     nsstring * storyboardname = [storyboard valueforkey:@"name"];     //in storyboard named vc2 "ctrl2" identifier      viewcontroller2 *temp =      [[uistoryboard storyboardwithname:storyboardname bundle:nil]     instantiateviewcontrollerwithidentifier:@"ctrl2"];     [self presentviewcontroller:temp animated:yes completion:null]; }  - (void)viewwillappear:(bool)animated{     nslog(@"in viewwillappear mystr %@", self.mystr); }  - (void)viewdidload{     [super viewdidload];     nslog(@"my str %@", self.mystr); } 

this relevant code in vc2.h

@class viewcontroller;  - (ibaction)btnclkd:(id)sender; @property(nonatomic, weak)viewcontroller *vc1obj; 

this relevant code in vc2.m

- (ibaction)btnclkd:(id)sender {     self.vc1obj.mystr = @"test";     nslog(@"setting mystr v2");     [self.presentingviewcontroller dismissviewcontrolleranimated:yes completion:nil]; } 

viewdidload in vc1 dont triggered when vc2 dismessed. have tried log both in viewdidappear , viewwillappear. in both case, mystr null. doing wrong?

it looks me though never setting vc2.vc1obj.

my recommendation in vc1's - (ibaction)btnclick:(id)sender; this:

- (ibaction)btnclick:(id)sender  {     //    in storyboard named vc2 "ctrl2" identifier      viewcontroller2 *temp = [self.storyboard instantiateviewcontrollerwithidentifier:@"ctrl2"];     temp.vc1obj = self;     [self presentviewcontroller:temp animated:yes completion:null]; } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -