将数组从控制器传递到视图 [英] Passing Array From Controller to View

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

问题描述

我有:

  1. UIView
  2. UIViewController

在UIViewController中,我需要能够将项目插入6个整数的固定数组中.然后,我需要将此数组传递给视图,以便它分析该数组并适当地更新屏幕.我该怎么做呢?我已经尝试过使用标准C数组,但似乎不起作用?

In the UIViewController I need to be able to insert items into a fixed array of 6 integers. Then, I need to pass this array to the view in order for it to analyse the array and update the screen appropriately. How do I go about doing this? I've tried using standard C arrays but doesn't seem to work?

推荐答案

您不能将C数组用作方法的参数,也不能将它们传递给某些东西.您有两种选择:

You can't use C arrays as arguments to methods, nor can you pass them to something. You have two options:

  1. 使用由六个NSNumber组成的NSArray,每个NSNumber包含一个int.
  2. 使用指向C数组的指针.

您选择哪一个取决于您.选项1更像iPhone.选项2的内存消耗较少.

Which one you choose is up to you. Option 1 is more iPhone-alike. Option 2 is less memory-consuming.

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

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