How to send an NSString to another view controller

后端 未结 4 1931
时光说笑
时光说笑 2020-12-22 11:20

I have an IBAction that when triggered calls another method in a different view controller ( APICallsViewController). I\'m looking to also send that method an NSString (m

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 12:10

    Declare a string in the viewcontroller to where you have to pass the string.And in the view from which you have to pass the string,in your case,set like apiViewController.stringintheotherview=message;

    The string in your APICallsViewController must be synthesized

     NSString *message = [NSString stringWithFormat:@"Check out %@", nameLb.text];
             APICallsViewController *apiViewController = [[APICallsViewController alloc] init];
     apiViewController.stringintheotherview=message;
                [self.navigationController pushViewController:apiViewController animated:YES]; 
    

提交回复
热议问题