ios - Delegate passing data no response -


i've been advised pass data using delegation, not seem show log message of string. i'm passing data frontviewcontroller backviewcontroller.

frontviewcontroller.h

@protocol passiddelegate <nsobject>  -(void)idpassed:(nsstring*)idstring;  @end    @interface frontviewcontroller : uiviewcontroller {      id<passiddelegate> delegate; }  @property(nonatomic,assign)id delegate;  @end 

frontviewcontroller.m passing data in didselectrow

[delegate idpassed:[[homesdic objectatindex:indexpath.row] objectforkey:@"idstring"]];  [self performseguewithidentifier:@"showhome" sender:self]; 

backviewcontroller.h

@interface homeprofileviewcontroller : uiviewcontroller <passiddelegate>{  }  @end 

backviewcontrolller.m

-(void)idpassed:(nsstring*)idstring{     nslog(@"%@", idstring); } 

in case, trying pass data new view controller being presented, delegation isn't correct pattern. need property on destination view controller receive data.

backviewcontroller.h

@interface homeprofileviewcontroller : uiviewcontroller{  @property (strong,nonatomic) nsstring *idstring;  }  @end 

frontviewcontroller.m passing data in didselectrow

nsstring *idstring =  [[homesdic objectatindex:indexpath.row] objectforkey:@"idstring"]];  [self performseguewithidentifier:@"showhome" sender:idstring]; 

in frontviewcontroller.m prepareforsegue

-(void) prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {     if ([segue.identifier isequaltostring:@"showhome"]) {         homeprofileviewcontroller *hpvc = (homeprofileviewcontroller *)segue.destinationviewcontroller;         hpvc.idstring=(nsstring *)sender;     } } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -