[英]Swift3: Using Two Arrays to populate grouped Table
I currently have two populated arrays using a custom struct. 我目前有两个使用自定义结构的填充数组。
struct Group {
var id: String
var type: String
var desc: String
var name: String
init() {
id = ""
type = ""
desc = ""
name = ""
}
}
Data gets appended to: 数据附加到:
var clientArray: [Group] = []
var departmentArray: [Group] = []
I essentially want to join them together to have the format something like [[clientArray], [departmentArray]] so I can use "section" and populate two different groups on a table with the respective arrays. 我本质上想将它们连接在一起,使其具有类似[[clientArray],[departmentArray]]的格式,因此我可以使用“ section”并用各自的数组填充表上的两个不同组。
So far I've tried the following, but I get the error "fatal error: index out of range". 到目前为止,我已经尝试了以下操作,但出现错误“严重错误:索引超出范围”。
var masterArray = [[Group]]()
//Then further down the page...
self.masterArray[0] = self.clientArray
self.masterArray[1] = self.departmentArray
How can I get this to work? 我该如何工作? Thanks for any help.
谢谢你的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.