【问题标题】:Send array to next viewcontroller iOs xcode [duplicate]将数组发送到下一个viewcontroller iOs xcode [重复]
【发布时间】:2013-01-14 18:41:40
【问题描述】:

可能重复:
Passing Data between View Controllers

我有 2 个视图控制器:

  1. 索引
  2. 第二

在索引中,我有 2 个 textfieldbutton

我填写这个文本字段并按“下一步按钮”到第二个视图,我需要使用数组“显示”这两个文本字段(稍后我将发送 JSON 数据)。 我怎样才能最好地实现?请帮忙! 最好的问候
伊万。

【问题讨论】:

    标签: iphone ios xcode arrays xcode4.5


    【解决方案1】:

    Second 类中将@property 声明为textArray。然后在从Index 推送到Second 时,需要设置这个属性。

    Second.h 文件中,

    @property(nonatomic, strong) NSArray *textArray;
    

    Index.m 文件中,

    Second *aSecond = [[Second alloc] init];
    aSecond.textArray = @[textField1.text, textField2.text];
    //write code to push from Index to Second
    

    现在在Second 类中,您可以将其用作aSecond.textArray[0]aSecond.textArray[1]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多