简体   繁体   English

表达式解析为未使用的属性

[英]Expression resolves to an unused property

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
            }
        }
    }
}

EDIT: I'm now getting "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" as an Error. 编辑:我现在收到“线程1:致命错误:意外地发现零,而展开一个可选值时”作为错误。

This is the code of my DestinationVC 这是我的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
}
}

Expression resolves to an unused property 表达式解析为未使用的属性

This error means, that you wrote code with reference for some property of some item in jobs array, but you haven't done anything with it (declare some constant, change some variable, etc.) 这个错误的意思是,您为jobs数组中某个项目的某些属性编写了引用代码,但是您并未对其进行任何操作(声明一些常量,更改某些变量等)。

You probably just wanted to declare Job item for specific row, so you can do it like this 您可能只想声明特定行的Job项目,所以您可以这样

let job = jobs[indexPath.row]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM