xcode - Access button from different controller (Objective-C) -
i've started making app in xcode need access button on different controller. can set controllers class viewcontroller first one? or need create new class , link them how?
you can pass object of interest view controller view controller b this:
// in view controller - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if([[segue identifier] isequaltostring:@"seguefromatob"]) { nsstring *myvalue = [_mytextfield text]; [(bviewcontroller *)[segue destinationviewcontroller] setmyvalue:myvalue]; } } // in view controller b @interface bviewcontroller () @property (nonatomic, strong) nsstring *myvalue; @end - (void)viewdidload { [super viewdidload]; // todo: evaluate myvalue here }
don't forget give segue (represented line connecting 2 controllers) b id in storyboard (e.g. "seguefromatob")
Comments
Post a Comment