Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何从三级结构读取变量?_Swift_Struct_Tableview - Fatal编程技术网

Swift 如何从三级结构读取变量?

Swift 如何从三级结构读取变量?,swift,struct,tableview,Swift,Struct,Tableview,我知道如何访问“struct-Course”变量并将它们放到tableview中。我是这样做的: var event = [Course]() //some code left out let courses = try JSONDecoder().decode(JsonFromWeb.self, from: data) self.event = courses.data //some code left out 然后在tableView中: func tableView(_ tableVie

我知道如何访问“struct-Course”变量并将它们放到tableview中。我是这样做的:

var event = [Course]()
//some code left out
let courses = try JSONDecoder().decode(JsonFromWeb.self, from: data)
self.event = courses.data
//some code left out
然后在tableView中:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "eventCell") as? UserEventsTableViewCell else { return UITableViewCell() }
        cell.idLabel.text = event[indexPath.row].id
        cell.nameLabel.text = event[indexPath.row].name
        return cell
    }
但我无法找到访问Cover变量并获取示例源值并将其添加到tableView的方法。就像我对课程变量所做的那样。 我的结构在这里:(归功于使用我的JSON编码的用户Vadian。)

希望能找到帮助。谢谢大家!

这很简单:

要访问
封面中的
源代码
,请使用

event[indexPath.row].cover?.source
event[indexPath.row].cover?.source