override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toDetails" {
if let indexPath = sender as? IndexPath {
if let nextVC = segue.destination as? JobDetailViewController {
let valueToPass = jobs[indexPath.row].text <- Thread1
let passUserName = jobs[indexPath.row].addedByUser
nextVC.jobDetail.text = valueToPass
nextVC.userLabel.text = passUserName
}
}
}
}
编辑:我现在收到“线程1:致命错误:在展开可选值时意外发现nil”作为错误。
这是我的DestinationVC的代码
@IBOutlet weak var jobDetail: RoundLabel!
@IBOutlet weak var userLabel: UILabel!
var valueToPass: String = ""
var passUserName: String!
override func viewDidLoad() {
super.viewDidLoad()
jobDetail.text = valueToPass
userLabel.text = passUserName
}
}
答案 0 :(得分:2)
表达式解析为未使用的属性
此错误意味着,您为jobs
数组中某项的某些属性编写了引用代码,但是您并未对其进行任何操作(声明一些常量,更改某些变量等)>
您可能只想声明特定行的Job
项目,因此您可以这样做
let job = jobs[indexPath.row]