将 NSMutableArray 从一个视图控制器复制到另一个视图控制器? [英] Copying of NSMutableArray from one viewcontroller to another viewcontroller?

查看:37
本文介绍了将 NSMutableArray 从一个视图控制器复制到另一个视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 FirstViewController 中有一个 NSMutableArray 声明为 firstArray.我想将 secondArray 复制到 firstArray 中.

I have one NSMutableArray in FirstViewController declared as firstArray. I want to copy the secondArray into firstArray.

在 SecondViewController 中,

In the SecondViewController,

Self.FirstViewController.firstArray = self.secondArray;

当我尝试 NSLog FirstViewController 中的 firstArray.count 时,它显示 0.它应该在数组中有两个对象

When I attempt to NSLog the firstArray.count from the FirstViewController, it display 0. It should have two objects in the array

有人可以就此提出建议吗?

Anyone can advise on this?

推荐答案

您可以选择以下解决方案之一:

You can choose one of this solutions:

  1. 单身
  2. ViewControllers
  3. 之间传递数据
  4. 委托

您可以在这里找到您需要的所有信息:https://stackoverflow.com/a/9736559/1578927

You can find all the info you need right here: https://stackoverflow.com/a/9736559/1578927

单例示例:

static MySingleton *sharedSingleton;

    + (void)initialize
    {
        static BOOL initialized = NO;
        if(!initialized)
        {
            initialized = YES;
            sharedSingleton = [[MySingleton alloc] init];
        }
    }

这篇关于将 NSMutableArray 从一个视图控制器复制到另一个视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆