【发布时间】:2020-10-27 19:38:51
【问题描述】:
所以我正在学习 Core Data,并且我设法创建了一个具有父关系的 segue,它允许我根据您在之前的 VC(A 类别视图控制器)中选择的类别来继续显示某些项目。现在我在此之后创建了一个单独的 VC,它根据您的位置显示天气,要访问它,您必须单击原始 VC(类别视图控制器)中的按钮才能访问 weatherViewController。但是,每次我尝试这样做并执行 segue 时,都会遇到以下错误:
这是我到目前为止的代码:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destinationVC = segue.destination as! NoteTableViewController
let weatherDestinationVC = segue.destination as! WeatherViewController
if let indexLocale = noteTableView.indexPathForSelectedRow {
destinationVC.selectionCategory = noteArray[indexLocale.row]
print(indexLocale.row)
} else {
print("Error")
weatherDestinationVC.delegate = self
performSegue(withIdentifier: "goToWeather", sender: self)
}
}
@IBAction func goToWeatherView(_ sender: UIBarButtonItem) {
performSegue(withIdentifier: "goToWeather", sender: self)
}
由于我只是在学习核心数据,因此我们将不胜感激!
【问题讨论】:
标签: ios swift core-data uiviewcontroller segue