我在应用程序中填充了一些数组。所以当我初始化它时,数组在某种程度上是空的。
当我的数组被所有nessecary数据填充时,我想将它们保存在多维数组中,以便用这些数据填充一个表,这些数据是按节排序的。
然而,我正在为如何用数据附加这个多维数组而挣扎。
这就是我最后想要的多维数组:
data in myServerInfo:
serverInfo(
[ping: "www.apple.com", serverStatusMain: "no data", statusImagesMain: "error"],
[ping: "www.google.com", serverStatusMain: "no data", statusImagesMain: "error"],
[ping: "www.amazon.com", serverStatusMain: "no data", statusImagesMain: "error"],
[ping: "www.bla.com", serverStatusMain: "no data", statusImagesMain: "error"]
)
我当前的实现如下所示:
struct serverInfo {
var pings: String
var serverStatusMain: String
var statusImageMain: String
}
var myServerInfo: [[serverInfo]] = []
let pings = ["www.apple.com", "www.google.com", "www.amazon.com", "www.bla.com"]
var statusImagesMain = ["error", "error", "error", "error"]
var serverStatusMain = ["no data", "no data", "no data", "no data"]
for i in serverStatusMain { //
myServerInfo.append([serverInfo(pings: pings[i], serverStatusMain: serverStatusMain[i], statusImageMain: statusImagesMain[i])])
}