ios - Passing data forward with delegates and UITabBarController -


i have uitabbarcontroller in application.

i trying pass data forward first tab second tab of application. in first tab have uitableviewcontroller , in didselectrowatindexpath method have code:

-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {      viewcontrollerb *viewcontrollerb = [self.tabbarcontroller.navigationcontroller.viewcontrollers objectatindex:1];     viewcontrollerb.array = self.filteredarray;       self.tabbarcontroller.selectedindex = 1; } 

this code executes okay , takes me second tab of uitabbarcontroller. viewcontrollerb.array property setting in viewcontrollerb nil , never set.

i tried use delegate pattern - seems pattern more suited backwards data passing.

can 1 me , tell me going wrong?

also - use delegates pass data forward? if - how?

thank assistance!

update - solution found

per @merlevedeless comment - correct code this:

-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {      uinavigationcontroller *navigationcontroller = [self.tabbarcontroller.viewcontrollers objectatindex:1];     viewcontrollerb *viewcontrollerb = navigationcontroller.viewcontrollers[0];      searchviewcontroller.array = self.suggestedsearcharray;       self.tabbarcontroller.selectedindex = 1; } 

i had viewcontrollerb embedded inside uinavigation controller.

shouldn't this

viewcontrollerb *viewcontrollerb = [self.tabbarcontroller.navigationcontroller.viewcontrollers objectatindex:1]; 

be this?

viewcontrollerb *viewcontrollerb = [self.tabbarcontroller.viewcontrollers objectatindex:1]; 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -