Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I keep getting this error: "Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit"

Tags:

swift

I keep getting this error:

Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit

even though I put the self in the code. Please correct me.

Here is my code:

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

There is more, but the yesAction needs correction.

like image 824
RPS1222 Avatar asked Sep 13 '25 18:09

RPS1222


1 Answers

performSegue is a method, which you're implicitly calling on self; the explicit version would be self.performSegue(...).

like image 167
hobbs Avatar answered Sep 15 '25 11:09

hobbs