Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在viewcontroller之间传递字符串_Objective C - Fatal编程技术网

Objective c 在viewcontroller之间传递字符串

Objective c 在viewcontroller之间传递字符串,objective-c,Objective C,我想使用属性(方法)将字符串从一个viewcontroller传递到另一个viewcontroller。有人能用objective c详细解释我吗?我们应该在属性(方法)中使用情节提要吗?如果您正在使用情节提要分段并希望在另一个ViewController上将stringA传递给stringB: - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] is

我想使用属性(方法)将字符串从一个viewcontroller传递到另一个viewcontroller。有人能用objective c详细解释我吗?我们应该在属性(方法)中使用情节提要吗?

如果您正在使用情节提要分段并希望在另一个ViewController上将stringA传递给stringB:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"YourVCIdentifier"])
    {
        YourViewController *yourVC = [segue destinationViewController];
        yourVC.stringB = stringA;
}
如果没有:

YourViewController *yourVC = [[YourViewController alloc] init];
yourVC.stringB = stringA;
[self presentViewController: yourVC animated:true completion:nil];

欢迎来到StackOverflow。请阅读以下关于如何提出适当问题的内容:请查看此链接,该链接解释了如何提出适当问题,不幸的是,您太宽泛了:。另外,我试着用你使用的标题在谷歌上搜索:第一页只包含来自StackOverflow的类似问题。也许你已经可以找到你需要的,如果你仍然有问题,我们会很乐意帮助你。