swift - 我不断收到此错误:“在闭包中隐式使用'self';使用'self。' 使捕获语义明确”
问题描述
我不断收到此错误:
Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
即使我将自我放入代码中。请纠正我。
这是我的代码:
@IBAction func doneButton(_ sender: Any) {
let code = codeTextField.text
if code == "TEST" || code == "Test" || code == "test" {
var myAlert = UIAlertController(title:"Alert", message: "You are logging into The Test Zoo, right?", preferredStyle: UIAlertController.Style.alert)
let yesAction = UIAlertAction(title: "Yes", style: UIAlertAction.Style.default) {
UIAlertAction in
performSegue(withIdentifier: "welcomeButton", sender:self)
}
还有更多,但 yesAction 需要更正。
解决方案
performSegue
是一种方法,您正在隐式调用它self
;显式版本是self.performSegue(...)
.
推荐阅读
- monitoring - 在服务结构上部署日内瓦监控代理时,MetricsExtension.Native.Exe 未运行
- gcc - C 和
文件 - java - Tomcat Servlet:src/main/webapp/WEB-INF 时为 404 状态,root/WEB-INF 时没有错误
- python - 如何将列表中的分隔符从“,”更改为“;” 不使用连接功能或任何列表操作
- r - R:计算总和小于给定值的三元组
- python - 如何基于另一个 DataFrame 中的列在 Pandas DataFrame 中创建新列?
- kubernetes - Pod 无法在 GKE 上访问自己的 IP
- r - 使用 R 中的 rvest 将网页抓取的表格保存在 csv 中
- javascript - 按顺序处理 websocket onmessage 事件
- angular - 如何从通用事件的子组件中执行父组件上的方法