如何在较大的阵列显示每个数组的值? [英] how to display the values of each array in larger array?
本文介绍了如何在较大的阵列显示每个数组的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我有
var array = [["Chinese"],["Italian"],["Thai"]]
和我期待设置这三个数组值的名称在表列表标记。
and I'm looking to set the names of these three array values to label in a table list.
我根本无法把我的
cell.namelabel.text = array.string
或类似的东西。
会有人可以推荐一个解决方案?
would anyone be able to recommend a solution?
推荐答案
- 以完成它的快速和肮脏的方式是在这里......
- A quick and dirty way to get it done is here.....
var array = [["Chinese"],["Italian"],["Thai"]]
cell.namelabel.text = array.string = array[0][0]
- 我们也可以重复使用换的
在阵列(即阵列)的阵列这里访问它们但是那只是一个办法做到这一点。
- One can also iterate using for-in
over the Array of Arrays (ie. array) here and access them but thats just one way to do it.
- 我们也可以尝试到阵列中的所有值取到一维数组
,所以访问变得更容易,如果多数民众赞成在code的动机。
- One can also try to fetch all the values in the array to a single dimension array
, so the access gets easier if thats the motive of the code.
var array = [["Chinese"],["Italian"],["Thai"]]
var valArray: [String] = []
for value in array
{
for innerValue in value
{
valArray.append(innerValue)
}
}
print(valArray)
这篇关于如何在较大的阵列显示每个数组的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文