【发布时间】:2018-02-10 11:50:38
【问题描述】:
所以我有 2 个视图控制器,我想在它们之间传递值并具有以下代码
@IBAction func analysisButton(_ sender: Any) {
if expensesRecieved.count > 0{
let categoryAnalysisController = storyboard?.instantiateViewController(withIdentifier: "CategoryVC") as! CategoryAnalysis
// var categoryAnalysisController: CategoryAnalysis = CategoryAnalysis(nibName: nil, bundle: nil)
categoryAnalysisController.collection = collectionDisplayed.text
self.performSegue(withIdentifier: "categoryAnalysis", sender:(Any).self)
}
我想要做的是,如果费用接收的计数大于 0,则执行 segue 并传递值,如果不是,则发出警报并且不做任何事情。
过去我使用过 prepareSegue 方法,但从未这样做过。我尝试了几种方法,一种是这样的,但都没有奏效。请帮忙!
【问题讨论】: