-2

I'm the first iPhone developer. My problem is that I want to run 'performSegue' in the function. Works correctly within a typical button function. But I want to do it in a function. What should I do?

@IBAction func nextButtonFuc(_ sender: UIButton) {
       ...
       performSegue(withIdentifier: "moveScreen", sender: self) // it's worked
}

But it get Error

@IBAction func nextButtonFuc(_ sender: UIButton) {
       ...
       networkingCallback(objectvalue!,object,sender)
}
...
func networkingCallback( _ objectvalue: String,_ object: Any,_ send: UIButton) {
      performSegue(withIdentifier: "moveScreen", sender: send) //Error
      self.performSegue(withIdentifier: "moveScreen", sender: self) //Error
      self.performSegue(withIdentifier: "moveScreen", sender: send) //Error
}

How can I solve this problem?

performSegue(withIdentifier: "moveScreen", sender: send)

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

self.performSegue(withIdentifier: "moveScreen", sender: send) Error

Thread 18: signal SIGABRT

Thanks in advance

iosbegindevel
  • 307
  • 5
  • 20

1 Answers1

0

When I saw a thread related error, I thought about how to it. And I thought it was an error caused by the asynchronous system. So I solved the problem through asynchronous execution.

DispatchQueue.main.async { self.performSegue(withIdentifier: "makeNickname", sender: self) }
iosbegindevel
  • 307
  • 5
  • 20