<分区>
我正在尝试调用要在 TableView 中打印的数组。唯一的问题是数组 (numbersWithCreationDate) 的类型为 [(Int,String)]
。我怎样才能让 numbersWithCreationDates 在这里工作。所以可以打印文本。它说这是行不通的,因为它只能接受一个字符串。
cell.textLabel?.text = numbersWithCreationDates[indexPath.row]
<分区>
我正在尝试调用要在 TableView 中打印的数组。唯一的问题是数组 (numbersWithCreationDate) 的类型为 [(Int,String)]
。我怎样才能让 numbersWithCreationDates 在这里工作。所以可以打印文本。它说这是行不通的,因为它只能接受一个字符串。
cell.textLabel?.text = numbersWithCreationDates[indexPath.row]
最佳答案
获取元组:
// Get the tupel at index of the current row
let tupel = numbersWithCreationDates[indexPath.row]
获取字符串:
// Get the second value of the tupel, the string value ...
let string = tupel.1
cell.textLabel?.text = string
关于ios - 将 (Int, String) 转换为 String 以打印数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43946119/
相关文章:
ios - 我如何通过通用链接使用深度链接打开同一个应用程序
android - 将照片存储/移动到手机中单独的应用程序文件夹
ruby - 解析字符串时使用 case 语句时避免/删除 nil
c - 初始化后无法将字符串放入数组中 - 使用适用于 ARM 的 TI 编译器 5.1.8 的 CCS 6
ios - Safari iOS 调试 URL 未显示,检查器显示 "null"
ios - iTunes 连接 : Availability of app to all territories not reflecting
swift - 一元运算符 '--' 不能应用于 '@lvalue Int?' 类型的操作数(又名 '@lvalue Optional<Int>' )