I want to pass a string from one viewcontroller to another using properties (approach). Can anyone explain me in detail using objective c? Should we use storyboard in properties(approach)?
Asked
Active
Viewed 24 times
-3
-
Welcome to StackOverflow. Please read this on how to ask a proper question: https://stackoverflow.com/help/how-to-ask – koen Jun 12 '18 at 13:20
-
Please have a look at this link, which explains how to ask a proper question, unfortunately you are too broad: https://stackoverflow.com/help/how-to-ask . Plus I've tried searching on Google with the title you used: the first page contains only similar question from StackOverflow. Probably you can already find what you need, in case you have still problem we will be happy to help. – Marco Pace Jun 12 '18 at 13:21
1 Answers
1
If you are using storyboard segues and want to pass stringA to stringB on another ViewController:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"YourVCIdentifier"])
{
YourViewController *yourVC = [segue destinationViewController];
yourVC.stringB = stringA;
}
If not:
YourViewController *yourVC = [[YourViewController alloc] init];
yourVC.stringB = stringA;
[self presentViewController: yourVC animated:true completion:nil];

Mykod
- 587
- 1
- 5
- 16