Swiftのビューコントローラから別のビューコントローラにデータを渡そうとしています。ビューコントローラ間でデータを渡す際にエラーが発生しました
ビューコントローラ1:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let selectedFiName = self.fetchedFiName[indexPath.row].fiName
let selectedOneYear = self.fetchedFiName[indexPath.row].oneYear
let selectedTwoYear = self.fetchedFiName[indexPath.row].twoYear
let selectedThreeYear = self.fetchedFiName[indexPath.row].threeYear
let selectedFourYear = self.fetchedFiName[indexPath.row].fourYear
let selectedFiveYear = self.fetchedFiName[indexPath.row].fiveYear
passData = [SecondTable(passedFIName: selectedFiName, passedOneYear: selectedOneYear, passedTwoYear: selectedTwoYear, passedThreeYear: selectedThreeYear, passedFourYear: selectedFourYear, passedFiveYear: selectedFiveYear)]
performSegue(withIdentifier: "SecondViewController", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let selectedFiName = sender as! ,
let destVC = segue.destination as? SecondViewController {
destVC.fiName = selectedFiName
}
}
エラーは、ビューコントローラ2(receieving)の "セグエの準備" に示す:
struct SecondTable {
var passedFIName: String = ""
var passedOneYear: String = ""
var passedTwoYear: String = ""
var passedThreeYear: String = ""
var passedFourYear: String = ""
var passedFiveYear: String = ""
}
class SecondViewController: UIViewController {
@IBOutlet weak var fiName: UILabel!
@IBOutlet weak var sometext: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let fiDetails = SecondTable()
fiName.text = SecondTable.passedFIName
sometext.text = "Some Text"