I have parsed a json file with the following structure into a table view succesfully.
import Foundation
struct ActionResult: Codable {
let data3: [Datum]
}
struct Datum: Codable {
let actionGoal, actionGoalDescription, actionGoalImage: String
let actions: [Action]
}
struct Action: Codable {
let actionTitle: String
let actionID: Int
let select, completed, favorite: Bool
let actionType, actionDescription, actionTips, actionImage: String
let actionSponsor, actionSponsorURL: String
Now I am preparing a segue to a detail ViewController but is giving me an error.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "showDetail", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination = segue.destination as? ActionDetailViewController {
destination.action = result?.data3.actions[(tableView.indexPathForSelectedRow?.row)!]
Error description. Value of type '[Datum]' has no member 'actions' Who can help me?
Additional info: DetailViewController set up
import UIKit
import SwiftUI
class ActionDetailViewController: UIViewController {
@IBOutlet weak var ActionImageDetail: UIImageView!
@IBOutlet weak var ActionTitleDetail: UILabel!
@IBOutlet weak var ActionDescriptionDetail: UITextView!
@IBOutlet weak var ActionTipsDetail: UITextView!
var action: Action?
override func viewDidLoad() {
super.viewDidLoad()
ActionTitleDetail.text = action?.actionTitle
ActionImageDetail.image = UIImage(named: action!.actionImage)
ActionDescriptionDetail.text = action?.actionDescription
ActionTipsDetail.text = action?.actionTips
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}